Solved

delete all access tables with a prefix

Posted on 2015-01-26
2
136 Views
Last Modified: 2015-08-03
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.
0
Comment
Question by:SFWolverine
  • 2
2 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 40571332
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
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 500 total points
ID: 40571448
to delete the excel files

dim strPath as string, xlFile as string
strPath="C:\"
xlFile=dir(strPath & "*.xls")
while xlFile <>""
    if xlfile like "sample_*" then
       kill strPath & xlFile
    end if
    xlFile=dir
wend
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Office 365 home questions 7 65
Combobox row source 2 19
Question about DB Schema 27 50
Merging spreadsheets 8 29
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
This video teaches viewers about errors in exception handling.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

815 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now