getting rid of system notices

I can't get rid of the following notice:  
"The DoMenuItem action was canceled.  You used a method of the DoCmd object to carry out an action in Visual Basic, but then clicked Cancel in a dialog box..."

I've used the setwarnings command to turn off system messages, but it doesn't get rid of this particular one.

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Is this on a form, I take it? What happens when you get this message? I usually get it when I send something to print and then cancel or when my code hits an error which causes Access to cancel something.

This isn't considered one of Access' system warnings -- it's an actual error (2501, I think). That means you'll have to trap it.
I've gotten this same message a couple of times when performing a TransferText on a locked text file.  The cause of the problem was a timed out FTP session which was used to transfer the text file from our mainframe.  I had to reboot to release the lock and the TransferText then worked fine.


I run into this all the time when using a command button to open a form that uses a parameter query as a datasource or has a construct similar to "[Enter Customer]" in the QBE grid as criteria.  If your command button opens the form, then the query will display an input box for the parameter.  If you then click cancel, the form can't open because the query can't run without parameters.

I believe the best solution is to use a form to gather input, process the input, and then open the form only when you've got good parameters from the user.

If this isn't the case, gleefully ignore my comment and let us know the exact conditions that give you the error message.

The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

jptuAuthor Commented:
I don't think it is an error message, because my procedure doesn't jump to the error messge that I specify when this error occurs.  I get this error when I switch to another form.  However, before switching, it will ask if the user wants to save the form first.  If yes, then it goes to save the form, but it must pass some validation rules first.  If it doesn't pass, then the save is cancelled and the form is not switched.

jptuAuthor Commented:
wesleystewart- I was thinking of doing that too.  I will wait a bit more for additional comments before taking this approach.  Thanks.

Set a flag to indicate where in the code you are, (I have a gloabl string 'wher' which I use as the WHERE part of domain aggregate functions, and as a 'flag' in error handlers to show where I am.)

Then in the error handler, ignore Err.Number 2501 if you are at the part of code that could have an 'object open' cancelled:


   On Error goto ErrHndl

   wher = "Opening 1st form"
   wher = ""

   Exit Sub

   Select Case wher
      Case "Opening 1st form"
         If Err.Number = 2501 Then
            Resume Next
         End If
      Case "...."
   End Select

   ' If you get to here, the error
   ' isn't any of the things you've
   ' trapped for, so use your regular
   ' method of handling errors...
   MsgBox Err.Number & ", " & _
   Resume SubExit


It's true that the message you are getting is not a warning.  It also is not really an error, per se.  In many instances the 'error' functionality of Access is used as a notification system--a system which can assert itself strongly...  (It's more like a 'non-maskable interupt' in code.)

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
glad you got an answer. Just curious (for me and others who might look at this later): what was the situation, and how did BrianWren's comment solve it?
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.