Suppress Action Query Alerts

  • Thread starter Thread starter Deb Roberts
  • Start date Start date
D

Deb Roberts

Is there any way that I can prevent an automatic alert when I run an action
query?

Currently when it runs, I get a message about updating however many records,
and do I wish to proceed.

I actually want to add this query to the on-close event of a form, and don't
want the users to be bothered with the alert.

Is there any way to suppress this message??

Thanks.
 
Is there any way that I can prevent an automatic alert when I run an action
query?

Currently when it runs, I get a message about updating however many records,
and do I wish to proceed.

I actually want to add this query to the on-close event of a form, and don't
want the users to be bothered with the alert.

Is there any way to suppress this message??

Thanks.

In an event....
DoCmd.SetWarnings False
DoCmd.OpenQuery "QueryName"
DoCmd.SetWarnings True
 
Is there any way that I can prevent an automatic alert when I run an action
query?

Currently when it runs, I get a message about updating however many records,
and do I wish to proceed.

I actually want to add this query to the on-close event of a form, and don't
want the users to be bothered with the alert.

Is there any way to suppress this message??

Yes; two ways.

- First, you can use a line

DoCmd.SetWarnings False

before executing the query. BE CERTAIN to also put

DoCmd.SetWarnings True

after the execution, or you'll turn off ALL your warning messages.

- Better, because it supports error handling, use the Execute method
of the Querydef object:

Dim db As DAO.Database
Dim qd AS DAO.Querydef
On Error GoTo Proc_Error
Set db = CurrentDb
.... <other code in ON CLOSE>
Set qd = db.Querydefs("your-query-name")
qd.Execute dbFailOnError


If there's an error during execution of the query control will pass to
the Proc_Error label and you can put code to take appropriate action.
 
Thank You !


John Vinson said:
Yes; two ways.

- First, you can use a line

DoCmd.SetWarnings False

before executing the query. BE CERTAIN to also put

DoCmd.SetWarnings True

after the execution, or you'll turn off ALL your warning messages.

- Better, because it supports error handling, use the Execute method
of the Querydef object:

Dim db As DAO.Database
Dim qd AS DAO.Querydef
On Error GoTo Proc_Error
Set db = CurrentDb
... <other code in ON CLOSE>
Set qd = db.Querydefs("your-query-name")
qd.Execute dbFailOnError


If there's an error during execution of the query control will pass to
the Proc_Error label and you can put code to take appropriate action.
 
Back
Top