Delete/Update prompts

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have sql in vba that does update and deletes..when they trigger a prompt
asking the user if they want to delete/update the table appears...How can I
stop that from happening and just have the statement go through?

thanks
 
Before your delete or update statement put
DoCmd.SetWarnings False

and after your statement put
DoCmd.SetWarnings True
 
Another alternative is to use CurrentDB.Execute to run the SQL statement.
Then there is no need to turn off/on the warnings. You might also want to
use the -dbfailonerror option since the execute function gives no indication
of success or failure.
 
DoCmd.SetWarnings False
DoCmd.RunSQL (or DoCmd.OpenQuery)
DoCmd.SetWarnings True

I'm in the habit of encapsulating the query to ensure that the warnings
are always turned back on afterward as there are times that I want to
see them, esp If I'm developing something or if theres the possibility
that the user may run a query.
 
I used to do this too. But what happens if the query pukes and causes an
error where you're presented with the good ol' "Debug or End" prompt? It
would be good to have some basic error handling in place to set the warnings
back to true in the event of an error. But, I'm sure we all have at least
some rudimentary error-handlers in each procedure. :-)
 
Well yeah, but currently all my stuff is for myself (I'm self-employed.)

David H
(VERY LONG several days)
 
Back
Top