Can DoCmd.RunSQL be Done Quietly?

  • Thread starter Thread starter croy
  • Start date Start date
C

croy

When running an action query using the DoCmd.RunSQL
function, can the resulting message(s), such as "You are
about to delete...." be avoided?
 
You can either bracket it with the SetWarnings command:

DoCmd.SetWarnings False
DoCmd.RunSQL
DoCmd.SetWarnings True

or use the Execute method of the database object:

CurrentDb.Execute "yourquery"

The second method has the advantage of being faster and you can trap errors.

--
--Roger Carlson
MS Access MVP
Access Database Samples: www.rogersaccesslibrary.com
Want answers to your Access questions in your Email?
Free subscription:
http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L
 
You can either bracket it with the SetWarnings command:

DoCmd.SetWarnings False
DoCmd.RunSQL
DoCmd.SetWarnings True

or use the Execute method of the database object:

CurrentDb.Execute "yourquery"

The second method has the advantage of being faster and you can trap errors.


Thanks, Roger. The SetWarnings way seems to work
beautifully. I haven't tried the Execute method, but I've
sure saved the info for future reference. Very helpful!
 
Roger Carlson said:
You can either bracket it with the SetWarnings command:

DoCmd.SetWarnings False
DoCmd.RunSQL
DoCmd.SetWarnings True

But also make sure you put the DoCmd.SetWarnings True line in the
error handling or wield things will start happening in your app. Or
rather expected warnings won't pop up especially when developing.

Tony
--
Tony Toews, Microsoft Access MVP
Please respond only in the newsgroups so that others can
read the entire thread of messages.
Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
 
Back
Top