Run silent

  • Thread starter Thread starter timdolezal
  • Start date Start date
T

timdolezal

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

Can someone help me?
 
Just make sure you issue

DoCmd.SetWarnings True

afterwards, to ensure you get legitimate popups!
 
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
 

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

Back
Top