message box confusion

  • Thread starter Thread starter JohnE
  • Start date Start date
J

JohnE

I am wanting to have a message box response either open
another form or move to the next field. If the msgbox
response is Yes then the form should open. If the msgbox
response is No then the focus moves to the next field. I
am using the following but it is not working properly.
Both the Yes and No open the form.

Private Sub cboVoucherEnteredTimely_AfterUpdate()
If Me.cboVoucherEnteredTimely.Value = "Yes" Then
MsgBox "Do you wish to add a new comment?",
vbYesNo, "COMMENT?"
If vbYes Then
DoCmd.OpenForm "usrfrmComments"
Else
Me.cboVoucherAccurate.SetFocus
End If
Else
Me.cboVoucherAccurate.SetFocus
End If

End Sub

What am I missing?
Thanks for any help.
*** John
 
John,

Try this:

If Me.cboVoucherEnteredTimely.Value = "Yes" Then
result = MsgBox "Do you wish to add a new comment?", vbYesNo,
"COMMENT?"
If result = vbYes Then
DoCmd.OpenForm "usrfrmComments"
Else
Me.cboVoucherAccurate.SetFocus
End If
Else
Me.cboVoucherAccurate.SetFocus
End If

Tom
 
Back
Top