DoCmd.RunSQL - I don't want warnings

  • Thread starter Thread starter Sheryl
  • Start date Start date
S

Sheryl

I'm doing an update in my VBA application
using 'DoCmd.RunSQL Qry'. I don't want it to prompt me
every time it performs the update. What do I set for that?

I do want to post a message and maybe bail out if an error
occurs. How do I do that?
 
You can do one of two things:
Bracket your command with SetWarnings

DoCmd.SetWarnings False
DoCmd.RunSQL...
DoCmd SetWarnings True
(ALWAYS set them back on)

On the other hand, you could use the Execute method of the Database object:

CurrentDb.Execute Qry


Neither of these will ask you for confirmation.
 
-----Original Message-----
I'm doing an update in my VBA application
using 'DoCmd.RunSQL Qry'. I don't want it to prompt me
every time it performs the update. What do I set for that?

I do want to post a message and maybe bail out if an error
occurs. How do I do that?
.
To turn off/on warnings use
DoCmd.SetWarnings False before you update and
DoCmd.SetWarnings True after you update.
 
Chip said:
To turn off/on warnings use
DoCmd.SetWarnings False before you update and
DoCmd.SetWarnings True after you update.

Either that, or don't use DoCmd.RunSQL. You can use the Execute method of
the Database, or of the QueryDef object.

CurrentDb.Execute strMySQL, dbFailOnError
 
Back
Top