Delete tables from the code

polina

Registered User.
Local time
Today, 08:32
Joined
Aug 21, 2002
Messages
100
Hello,

I was wondering if anyone could tell me how to delete the tables using VBA?

The trick is I woulnd't know the exact names of the tables. I would want to delete all the tables that contain "Errors" in their names.

Please advise.

Thanks.
 
I don't have the exact code, but the basic principle is loop through the table collection and use instr on the name property to find the substring you are looking for. Then delete the object (table) or get the next table name. Maybe someone else has code to do it.
 
Code:
    Dim tdf As TableDef
    
    For Each tdf In CurrentDb.TableDefs
        If InStr(1, tdf.Name, "Errors") Then
            DoCmd.DeleteObject acTable, tdf.Name
        End If
    Next
 
Thanks

"Errors" is just the part of the name of the table
 

Users who are viewing this thread

Back
Top Bottom