DoCmd.DeleteObject acTable, "TableName"

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When importing, Access always creates a table for import errors. (Since my
txt-file is a little funny.)
I want to delete it, but at this point I am not sure what the name of the
table is.
I only know it is [*ImportErrors*]
The person importing, should not have to check the table name and delete
this table manually.

How can I delete this table?

BR
Claes
 
You could loop through the Tables collection, and delete any table that has
ImportErrors in its name. Something like the following untested air-code:

Sub DeleteImportErrors()
Dim dbCurr As DAO.Database
Dim tdfCurr As DAO.TableDef
Dim intLoop As Integer

Set dbCurr = CurrentDb()

For intLoop = (dbCurr.TableDefs.Count - 1) To 0 Step -1
Set tdfCurr = dbCurr.TableDefs(intLoop)
If InStr(tdfCurr.Name, "ImportError") > 0 Then
dbCurr.TableDefs.Delete tdfCurr.Name
End If
Next intLoop

Set dbCurr = Nothing

Exit Sub
 
Back
Top