Suppressing Alerts

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
 
J

Jeff Boyce

Sheldon

DoCmd.SetWarnings False
...
DoCmd.SetWarnings True

Good luck

Jeff Boyce
<Access MVP>
 
K

Ken Snell [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.
 
G

Guest

Another technique is to use the Execute method.

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

Currentdb.execute strSQL

HTH
Dale
 

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