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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

deleting tables

Status
Not open for further replies.

sdimaggio

Technical User
Jan 23, 2002
138
US
How can I delete all the tables in a database at one time?

thanks in advance.
 
You can use a VBA module like the following.

Sub DeleteUserTables()

Dim tdf As DAO.TableDef

' Enumerate TableDefs collection.
For Each tdf In CurrentDb.TableDefs
If Left(tdf.Name, 4) <> &quot;msys&quot; Then
Debug.Print tdf.Name
CurrentDb.TableDefs.Delete (tdf.Name)
End If
Next tdf

Set tdf = Nothing

End Sub
Terry L. Broadbent - DBA
SQL Server Page:
If you want to get the best answer for your question read faq183-874.
 
I tried your suggestion on creating a VBA module. I ran into trouble with a warning sign stating:

Compile error
&quot;User defined type not defined&quot;

the following is highlighted (tdf As DAO.TableDef) as the problem.

Any suggestions? Does Access have a built in function that will delet all the tables at once instead of one at a time?

Steve
 
Check the References to make sure the Microsoft DAO 3.X Object Library is selected. Open the module in design mode, click on Tools | References. Select the latest version listed - probably 3.5 or 3.6. Terry L. Broadbent - DBA
SQL Server Page:
If you want to get the best answer for your question read faq183-874.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top