DoCmd.RunSQL - I don't want warnings

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?
 
R

Roger Carlson

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.
 
C

Chip

-----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.
 
D

Douglas J. Steele

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top