how do I automate the answering of "yes" to prompts that come about from running quereys?

i have a macro that executes several different quereys in a particular order.  Some of those quereys prompt for a yes or no before updating data.  I always want to answer yes, is there a way to automate this so that the macro can be run and i don't have to sit there to answer "yes" ?
Who is Participating?
BillPowellConnect With a Mentor Commented:
Sure, a couple of ways.

Add the SetWarnings to OFF to your macro, and then when your finished, turn them back on.

In code this is easily done by simply using.

Currentdb.execute "queryname"

This does not generate warnings.

Hope this helps,

The best way to run these queries is:

docmd.SetWarnings false               'This turns off all warnings and messages
docmd.OpenQuery "QueryName"     'This runs the query
docmd.OpenQuery "QueryName"     'This runs the query
docmd.SetWarnings true                'This turns on all warnings and messages

This is the code that you would place on the activating event.
RLGoldberg has given another good way to do this, although Id stop short of saying the best way.  Currentdb.execute does not generate warnings so therefore no need to turn them on or off.  If you do decide to go the Docmd route then make sure you add some code that ensures your warnings get turned back on event in the event of an error, or else your warnings will remain off even after the procedure is finished.


Bill has a good point.  The reason that I feel that this approach is better is that on some queries I want the user to respond and therefore it is easier to work with a single method and just turn the warnings on and off.  Good catch Bill.
a quick way without having to change code is to go to Tools/Options, Edit/Find tab and uncheck the relevant boxes in the Confirm tab
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.