Yes/No Msg Box

expublish

Registered User.
Local time
Today, 14:17
Joined
Feb 22, 2002
Messages
121
I have a command button on a form that runs a macro. On the On_Click command before the macro is run I would like a pop up msg box to say 'Are you sure...' with Yes/No options. Onbviously the yes will carry on the command and the no will return to the form no changes.

Any help is great,

Scott Lyndon.
 
Scott

You could use something along these lines:

Code:
Private Sub cmdExitDatabase_Click()

    Dim msg As String
        'Ask user if they want to exit database.
        msg = msg & "Are You Sure You Want To Exit The Database?"
        If MsgBox(msg, vbYesNo, "User Information!") = vbYes Then
        MsgBox "Good Bye", , "Thank You"
        'If vbYes then Quit student database, saving all changes.
        Application.Quit acQuitSaveAll
        Else
        Exit Sub
    End If

End Sub

If the user clicks Yes the they will Quit the application, if they clcik No they will return to the form containing the command button (cmdExitDatabase)

HTH

Graham
 
How can I change this to run a macro if they click yes?
 
Code:
Private Sub cmdExitDatabase_Click()

Dim msg As String
        'Ask user if they want to run the macro.
        msg = msg & "Are You Sure You Want To Run This Macro?"
        If MsgBox(msg, vbYesNo, "User Information!") = vbYes Then
        MsgBox "TITLE", , "YOUR_MESSAGE"
       'Run the macro
        DoCmd.RunMacro "MACRONAME"
    Else
        Exit Sub
    End If

End Sub
 
Last edited:

Users who are viewing this thread

Back
Top Bottom