Getting rid of error

LaurieW

Registered User.
Local time
Today, 15:30
Joined
May 9, 2002
Messages
99
I have this code on my form's BeforeUpdate event. It is checking to make sure 2 required fields are filled before saving:

Private Sub Form_BeforeUpdate(Cancel As Integer)
If IsNull(Status) Then
MsgBox "Status is required; please select a Status from the list.", vbExclamation, "Terminations Data Entry"
Status.SetFocus 'place cursor in Status field
Cancel = True 'cancels saving the record
ElseIf IsNull(StatusDate) Then
MsgBox "Status Date is required; please enter Status Date", vbExclamation, "Terminations Data Entry"
StatusDate.SetFocus 'place cursor in Status Date field
Cancel = True 'cancels saving the record
End If
End Sub

The message boxes come up just fine, but then I also am receiving this error:

"The DoMenuItem action was canceled."

How do I get rid of this error showing up? I've tried lots of things but am stuck.

Thanks for your assistance.
 
You can set warnings to off just before your cancel statement and set them back to on just after. Check Access help for "setwarning"

Caveat Emptor: Always be careful to turn your warnings back on!

--Latin Mac
 
Doesn't work

I already tried the "DoCmd.SetWarnings False" and it doesn't work. I still keep getting this "The DoMenuItem Action was canceled" error box after my message box closes.

Any other ideas?
 
Two things:

(1) You might try putting your checking code into the individual BeforeUpdate events of the respective controls rather than the form. Just a thought.

(2) Add an undo into your code. See this thread, among others (search the forum on "cancel and save and message").

--Grasping Mac
 

Users who are viewing this thread

Back
Top Bottom