Solved

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

Posted on 2004-04-10
7
195 Views
Last Modified: 2008-03-06
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" ?
0
Comment
Question by:sixstringstu
  • 2
  • 2
7 Comments
 
LVL 11

Accepted Solution

by:
BillPowell earned 125 total points
ID: 10799740
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,

Bill
0
 
LVL 3

Expert Comment

by:RLGoldberg
ID: 10799813
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.
0
 
LVL 11

Expert Comment

by:BillPowell
ID: 10799906
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
0
 
LVL 3

Expert Comment

by:RLGoldberg
ID: 10799921
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.
0
 
LVL 65

Expert Comment

by:rockiroads
ID: 10808246
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
0

Featured Post

Migrating Your Company's PCs

To keep pace with competitors, businesses must keep employees productive, and that means providing them with the latest technology. This document provides the tips and tricks you need to help you migrate an outdated PC fleet to new desktops, laptops, and tablets.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.

773 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question