Link to home
Start Free TrialLog in
Avatar of sixstringstu
sixstringstu

asked on

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" ?
ASKER CERTIFIED SOLUTION
Avatar of BillPowell
BillPowell

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of RLGoldberg
RLGoldberg

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.

Regards,

Bill
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.
Avatar of rockiroads
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