Delete Objects Errors

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?
 
S

Steve Schapel

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.
 
R

Ripper

Thanks Steve. That worked perfectly! Since I am already deleting the table
it doesn't matter if I make one over existing ones.
 

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