How to define buttons from a vbYesNoCancel MsgBox? (1 Viewer)

Ironis

Learning Member...
Local time
Today, 19:15
Joined
Oct 10, 2002
Messages
61
I have a little problem with a msgbox. I have predefined the style like this:

PHP:
    Style2 = vbYesNoCancel + vbQuestion + vbDefaultButton1

I defined the next code, to give the commands to each button on the msgbox, but it doesn;t work properly.
If you enter vbNO, it will trigger the vbCancel command, if I change the code for vbCancel and vbNo, turn them around, then it will do on both the vbNo command. How can I fix this??

PHP:
'If OK, then save reservation, and say reservation is successful'
            If MsgBox(Msg2, Style2, Title2) = vbYes Then
                DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
                MsgBox Msg3, Style3, Title3
            ElseIf vbCancel Then
'Otherwise, delete reservation, and say reservation is cancelled'
                DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
                cmbResPersID.SetFocus
                MsgBox Msg5, Style5, Title5
'Go to check 3PM availability'
            ElseIf vbNo Then
                If MsgBox(Msg4, Style4, Title4) = vbOK Then
                    'E9AMAdv3PMLess6'
                End If
            End If
 

pdx_man

Just trying to help
Local time
Today, 15:15
Joined
Jan 23, 2001
Messages
1,347
Try getting your reponse first, then process on it:

Code:
Dim Reply as Variant

Reply = MsgBox(Msg2, Style2, Title2)
Select Case Reply
'If OK, then save reservation, and say reservation is successful
            Case vbYes:
                DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
                MsgBox Msg3, Style3, Title3
            Case vbCancel:
'Otherwise, delete reservation, and say reservation is cancelled
                DoCmd.DoMenuItem acFormBar, acEditMenu, acUndo, , acMenuVer70
                cmbResPersID.SetFocus
                MsgBox Msg5, Style5, Title5
'Go to check 3PM availability
            Case vbNo:
                If MsgBox(Msg4, Style4, Title4) = vbOK Then
                    'E9AMAdv3PMLess6
                End If
End Select
 

Ironis

Learning Member...
Local time
Today, 19:15
Joined
Oct 10, 2002
Messages
61
Think that will work, thanks alot!!
If it doesn't work, i will check back sunday (having weekend fri / sat)
Tnx!

Dennis (Ironis :cool: )

< edit >
Oke it works, thanks alot for helping me out on this one :)
 
Last edited:

Users who are viewing this thread

Top Bottom