yes or no message box

rkaria

Registered User.
Local time
Today, 15:09
Joined
Nov 19, 2009
Messages
48
Hi All

Im trying to have a command button so that when you click on it you will get a message and then the option to answer yes or no buttons.

If they select yes one report will open and if they select no another report will open.

does anyone know how I would start this coding?

THanks
R
 
I found the answer if anyone every needs it


Private Sub Command31_Click()
DoCmd.SetWarnings False
If MsgBox("Would you like to see summary version", vbYesNo, "title") = vbYes Then
DoCmd.OpenReport "claimsbypartno/warrantycode-product summary", acViewPreview
Else
DoCmd.OpenReport "claimsbypartno/warrantycode-product", acViewReport
End If
End Sub
 
Thats not the greatest/cleanest code but if you want to go ahead with it you should at least SetWarnings to True before you end the sub
 
There is no reason there to set warnings to false. Remove that line!
 
Code:
Dim Msg, Style, Title, Response, MyString

'Put something here that fires off the Yes No

    If  a = b Then

'Message box details
   
        Msg = ("First line of your message" & vbNewLine & _
        "Second line of your message"& vbNewLine & vbNewLine & _
         "New paragraph")

'Style of your message box
        Style = vbYesNo + vbQuestion + vbDefaultButton2
        Title = "Title of your message box goes here"
        Response = MsgBox(Msg, Style, Title)

'What to do if user clicks on Yes or No
 
            If Response = vbYes Then
                MyString = "Yes"
 'do something if yes

            Else

                MyString = "No"
                Cancel = True
'do something if no

            End If
 

Users who are viewing this thread

Back
Top Bottom