Suppressing Alerts

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

Guest

I am executing a query that creates a table from a TEMPLATE table.

SQL = "SELECT * INTO tbl" & Me.txtNewStockName & " "
SQL = SQL & "FROM tblTemplate"

When I run the following command to execute the query I get an alert message

DoCmd.RunSQL SQL

The message is
You are about to paste 0 row(s) into a new table.

etc, etc...

How do suppress this warning, and then turn warnings back on after the
statement has executed?

Thanks
 
Sheldon

DoCmd.SetWarnings False
...
DoCmd.SetWarnings True

Good luck

Jeff Boyce
<Access MVP>
 
DoCmd.SetWarnings False
DoCmd.RunSQL SQL
DoCmd.SetWarnings True

If you're using an error handler, be sure to put the DoCmd.SetWarnings True
step in the error handler too, or in an "exit" routine through which the
code will always pass; otherwise, the warnings alert messages will be turned
off throughout the database until you turn them back on programmatically.
 
Another technique is to use the Execute method.

strSQL = "SELECT * INTO tbl" & Me.txtNewStockName & " "
strSQL = strSQL & "FROM tblTemplate"

Currentdb.execute strSQL

HTH
Dale
 
Back
Top