Link to home
Start Free TrialLog in
Avatar of SFWolverine
SFWolverine

asked on

delete all access tables with a prefix

I have a list of tables in an access mdb ... i want to delete all tables with a particular prefix within the mdb and delete the tables in a directory with the same table names.  For example:  tables -- sample_1, sample_2 ... (all tables beginning with "sample" would be deleted) and a directory "C:/" ... there are tables sample_1.xls, sample_2.xls, ... these table would also be deleted.
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

this codes will delecte all tables with prefix mentioned above in the db

dim db as dao.database, td as dao.tabledef

for each td in db.tabledefs
if td.name like "sample_*" then
   db.execute "drop table " & "[" & td.name & "]"
next
ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial