message box confusion

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
 
T

TomU

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top