Run silent

T

timdolezal

I want to be able to delete a table and not be prompted with any
questions.

Can someone help me?
 
D

Douglas J. Steele

Just make sure you issue

DoCmd.SetWarnings True

afterwards, to ensure you get legitimate popups!
 
T

Tim Ferguson

Found my answer.

DoCmd.SetWarnings False

Here's a better one:

daoSQL = "DROP TABLE MyOldTable"
db.Execute daoSQL, dbFailOnError


It's better because you get a proper trappable error (if you don't have
permission to drop the table, or the table doesn't exist, and so on); and
because you can't forget to switch SetWarnings back on again.

By the way, if you are going to re-create the table again afterwards, it is
often easier and kinder to the mdb file to empty out the rows instead:

daoSQL = "DELETE FROM MyOldTable WHERE TRUE"
db.Execute daoSQL, dbFailOnError

All the best


Tim F
 
Top