deleteing tables

D

DD

I have tables that are created when i import a file to my database. the
tables are called sheet1$_errors
sheet1$_errors1
sheet1$_errors2
and so on.

i would like to run a macro that would delete these tables containing the
word sheet1*.*

if the tables do not exist, i do not want an error message displaying that
the tables dont exist. is there a way to do this.

thanks
 
S

Steve Schapel

DD,

To do this with a macro, you would need to use a DeleteObject action for
each table or potential table. In order to avoid the "table doesn't
exist" error messages, you would need to run a MakeTable Query for each
table before the DeleteObject action. If the table doesn't exist, it
will now, and the DeletObject will then proceed without incident. If
the table already exists, the MakeTable will simply overwrite it, which
doesn't matter since it is getting trashed anyway. So, the macro will
look something like this...
SetWarnings / No
OpenQuery
MakeTablesheet1$_errors1
DeleteObject
Table, sheet1$_errors1
OpenQuery
MakeTablesheet1$_errors2
DeleteObject
Table, sheet1$_errors2
etc
 

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