How to suppress "DoMenuItem action was cancelled"?

G

Guest

Windows XP, MS Access 2K
=====================
Hi,

I have a button on my form to save the current new record. I also have code
in form's BeforeUpdate event to do data validation. When I intentionally
leave a required field blank and click on the Save button, the code in
BeforeUpdate gets executed, and the custom error message is displayed.

But, my custom error message is followed by another message that says
"DoMenuItem action was cancelled.". I'm not sure why this warning message is
being displayed, and how can I turn it off? I tried adding Docmd.setwarnings
(False) at the beginning of code in BeforeUpdate (and remembering to turn
them on when I exit), but the message is still being displayed.

Any ideas on how to handle this?

Here's the code snippet in BeforeUpdate:
=========================================
MsgBox "Inside Before Update"
DoCmd.SetWarnings (False)

If Len(Me.RequestTitle & "") = 0 Then
Cancel = True
MsgBox "Please enter a name or title for your request."
Me.RequestTitle.SetFocus
Exit Sub
ElseIf
......
End If
=========================================

Thanks!

-Amit
 
W

Wayne Morgan

The error is being generated in the button's code, not in the BeforeUpdate
code. Try setting Warnings off in the button's code instead. If that doesn't
work, then you should be able to use VBA error handling to trap the error.
 
G

Guest

Hi Wayne,

Thanks for your answer, and yes, that was the correct reason. I did have the
"DoCmd.Setwarnings False" statement in the OnClick property, but not at the
very beginning of the code. Once I moved the code up, I stopped getting the
warning regarding DoMenuItem.

Thanks for your help!!

-Amit
 

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