Delete tables on Exit

  • Thread starter Thread starter jcote
  • Start date Start date
J

jcote

Guest
I'm trying to find a short way to delete specific tables (that may or may not exist) when exiting a form. As it is now I'm using an "On Error" statement to call a sub procedure to handle missing tables, but I know there has to be a better way.
 
Try this on the form's Close event:

Dim tdf As TableDef
Dim db As Database

Set db = CurrentDb

For Each tdf In db.TableDefs
If tdf.Name = "TableName" Then
DoCmd.SetWarnings False
DoCmd.DeleteObject acTable, "TableName"
DoCmd.SetWarnings True
Exit For
End If
Next

Set db = Nothing


substitute your table for "TableName"
 

Users who are viewing this thread

Back
Top Bottom