用户按“否”时显示消息框

时间:2014-03-06 13:06:48

标签: ms-access access-vba

我有以下代码从访问中的表中删除所有数据。然而,我还想要显示一个消息框,说“当用户按下NO时,当屏幕弹出”你确定......时,你没有删除anthing。“

有人知道我怎么能创造这样的东西吗?

Public Function DeleteDataSAP()

DoCmd.RunSQL "DELETE * FROM tb_Organisatiestructuur"

End Function

1 个答案:

答案 0 :(得分:1)

试试这个

Sub main()

    Dim retval
    retval = MsgBox("Are you sure you want to delete?", vbYesNo + vbDefaultButton2)

    If retval = vbYes Then
        DeleteDataSAP
    ElseIf retval = vbNo Then
        MsgBox "ok you didn't delete anthing "
    End If
End Sub


 Public Function DeleteDataSAP()

        DoCmd.RunSQL "DELETE * FROM tb_Organisatiestructuur"

    End Function