Deleting table links using a wildcard

W

WSF

Access97
Is it possible to use something like the "DoCmd.DeleteObject acTable
etc" to delete a table link using a wildcard?
We create temporary tables, for example by week numbers, and need to
delete them from time-to-time.

So we may have a table links called Week30, Week31, Week33 etc

Can I delete these all at once with something like "Week*" ??

Cheers,
WSF
 
G

Graham Mandeno

Not exactly, but it is fairly easy to do. Just enumerate the tables
collection and chech the name of each table:

Dim db as database, tdf as tableDef, i as Integer
Set db = CurrentDb
with db.TableDefs
For i = .Count - 1 to 0 step -1
If Left(.Item(i).Name, 4) = "Week" then
.Delete .Item(i).name
End If
Next i
End With

The reason for counting downwards, not upwards, is that when you delete a
member from a collection the indexes of all the "higher" members change.
 

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