Automate Key Stroke on an Update Query

new_2_prog

Registered User.
Local time
Yesterday, 23:11
Joined
Aug 4, 2008
Messages
58
I have a query that clears out check marks before form closes but I want it to be automated so the user doesn't answer the question "Do you want to run query", "Do you want to update X records" how do I write that in the code?

Thanks!
 
Depending on what the query does. If it flips a field in a table to Yes/No, then you can certainly just do do something like
Code:
currentdb.execute YOUR_QUERY
 
on the unload event add the following code.
Docmd.SetWarning false
Docmd.Openquery ""
Docmd.SetWarning true
 
on the unload event add the following code.
Docmd.SetWarning false
Docmd.Openquery ""
Docmd.SetWarning true

EZFriend's is better and one I would suggest over using the DoCmd.SetWarnings
Code:
currentdb.execute YOUR_QUERY

If you do use the DoCmd.SetWarnings then you really need to have an error handler on that event and the very first line should be

DoCmd.SetWarnings True

so that if it errors out before it can get to the reset it will reset it in the error handler or else you will find yourself without any warnings at all. And, that can be bad. So, again I suggest the CurrentDb.Execute method as you don't need to mess with the warnings.
 

Users who are viewing this thread

Back
Top Bottom