The following If...Then block is supposed to perform different commands on form based on whether the user clicks vbYes, vbNo, or vbCancel. It all works except for the vbCancel. If the user clicks vbCancel, I want the form to close. What happens instead is that the MsgBox closes and the focus goes to the form. Can anyone tell me what I'm doing wrong here? Many thanks in advance!
If intEntityID <> intPREntityID Then
If MsgBox(Msg, vbQuestion + vbYesNoCancel + vbDefaultButton2) = vbYes Then
DoCmd.GoToRecord , , acNewRec
DoCmd.Maximize
Forms!frmPartnersRelations!EntityID = Me.EntityID
Forms!frmPartnersRelations!ProjectID = Me.ProjectID
ElseIf vbNo Then
DoCmd.GoToRecord , , acFirst
DoCmd.Maximize
Else
DoCmd.CancelEvent
DoCmd.Close
End If
End If lastout (the game's not over till it's over)
If intEntityID <> intPREntityID Then
If MsgBox(Msg, vbQuestion + vbYesNoCancel + vbDefaultButton2) = vbYes Then
DoCmd.GoToRecord , , acNewRec
DoCmd.Maximize
Forms!frmPartnersRelations!EntityID = Me.EntityID
Forms!frmPartnersRelations!ProjectID = Me.ProjectID
ElseIf vbNo Then
DoCmd.GoToRecord , , acFirst
DoCmd.Maximize
Else
DoCmd.CancelEvent
DoCmd.Close
End If
End If lastout (the game's not over till it's over)