Delete Objects Errors

  • Thread starter Thread starter Ripper
  • Start date Start date
R

Ripper

I have a database that I clear out between uses. No need to store
information from use to use. I use a macro to delete the temorary tables
that I create from various queries etc. However, I don't always need to
create all the temp tables, so when I use the macro with the Delete Object
function I get an Action Failed Error even though I set Warning to false.

How can I set a macro or some process to delete tables that are there and
skip over the tables that were not created?
 
Rip,

One workaround here would be to put in an OpenQuery action to run a
Make-Table query for each of the tables you want to delete. If the table
already exists, that will be fine. If it doesn't already exist, then it
will now, and thus the DeleteObject will not fail.

Other than that, you can write a VBA procedure/function to test for the
existence of the table. This would work by looping throught the database's
TableDef objects.
 
Thanks Steve. That worked perfectly! Since I am already deleting the table
it doesn't matter if I make one over existing ones.
 
Back
Top