Better Way to Delete Import Error Tables?

G

Guest

I am using the routine below to delete Import Error tables. Because of the
number of tables in the database, it takes quite a while. Is there a better
way? Perhaps some way of saying: "For Each tbl In cat.Tables tbl.Name Like
'*$_ImportErrors*' "?

Private Sub Delete_Import_Error_Tables()
On Error GoTo Delete_Import_Error_Tables_Error_Recovery
Dim cat As ADOX.Catalog
Dim tbl As ADOX.Table
Set cat = New ADOX.Catalog
cat.ActiveConnection = CurrentProject.Connection
For Each tbl In cat.Tables
If tbl.Name Like "*$_ImportErrors*" Then
DoCmd.DeleteObject acTable, tbl.Name
End If
Next tbl
Delete_Import_Error_Tables_Error_Recovery:
Exit Sub
End Sub
 
D

Douglas J. Steele

I don't think there's any other way. Certainly you cannot use a statement
like you're suggesting.
 
I

Igor Braurman via AccessMonster.com

Dim tbl As TableDef

For Each tbl In CurrentDb.TableDefs
If tbl.Name Like "*" & "Errors" Then
CurrentDb.TableDefs.Delete tbl.Name
End If
Next
CurrentDb.TableDefs.Refresh
 

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