Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Deleting objects using wildcards - can this be done? 2

Status
Not open for further replies.

EdwardA

Programmer
May 22, 2002
15
GB
All,

I'm using Access 97 and I need to build a routine that deletes objects (in this case, tables) according to a wildcard specification.

The table names all start the same way (tblx...), and there are almost 400 of them, so what I want to do is delete them all without having to specify their names.

The command I really want is something like:

DoCmd.DeleteObject acTable, "tblx*"

Obviously, this doesn't work. Does anybody have a workaround?

Your help much appreciated.

Ed.
 
Dim dbs As DAO.Database, tdf As DAO.TableDef
Set dbs = CurrentDb
For Each tdf In dbs.TableDefs
If Left(tdf.Name, 4) = "tblx" Then
DoCmd.DeleteObject acTable, tdf.Name
End If
Next
Set dbs = Nothing

You will need the Microsoft Data Access Objects 3.x Library selected in your References.

Test this 1st in a copy of your DB

Bill
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top