Message box code HELP!

G

Guest

I have a message box coded on a before update event. I need to know how to
change this code so if the users response is no the record/input will be
removed so the user can return to the switchboard to look up the order number
in another form.
The ordernumber is a required field so it will not allow the user to back
out without inputting something at this point.

Here is the current code.

Private Sub ordernumber_BeforeUpdate(Cancel As Integer)
If DLookup("ordernumber", "qry ordernumbers", "ordernumber=" &
ordernumber.Value) Then
Cancel = (MsgBox("Duplicate Order, Do you want to Proceed?", vbQuestion +
vbYesNo)) = vbNo
If Cancel = 0 Then
Me!duplicate = True


End If
End If
End Sub

Please HELP!
Barry
 
G

Guest

Tom Thanks for the help on this.

The Dim intresponse has me moving in the right direction.

However my problem continues to be that the form will not allow the user to
return to the switchboard after clicking No on the message box, without
completeing an entry. The user will need to go to another form to search for
the duplicate order number.

Is there a way to have the record they were inputing deleted so they can
exscape the form they were in without a record entry?

Barry
 
G

Guest

Thank you for the Direction Tom, I found the code I needed for the delete.

Below is the Code that accomplished this for any future readers of this post.

Private Sub ordernumber_BeforeUpdate(Cancel As Integer)
Dim intResponse As Integer
intResponse = MsgBox("Duplicate Order,Do you want to Proceed?", vbQuestion +
vbYesNo)
If intResponse = vbYes Then
Me!duplicate = True
Else
Cancel = True
If Me.Dirty Then
Me.Undo
End If
End If
End Sub


Thanks Again 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

Top