Delete backup tables : AllTables « Access « VBA / Excel / Access / Word






Delete backup tables

 
Public Sub DeleteBackupTables()
   Dim tbl As Variant
   For Each tbl In CurrentData.AllTables
      If InStr(1, tbl.Name, "Backup", vbTextCompare) > 0 Then
         If vbYes = MsgBox("Delete table " & tbl.Name & "?", _
                           vbYesNoCancel Or vbQuestion, _
                           "Confirm Table Deletion") Then
            DoCmd.DeleteObject acTable, tbl.Name
         End If
      End If
   Next
   
End Sub

 








Related examples in the same category

1.iterates the AllTables collection, opens each nonsystem table, prints its structure, and then closes the open table.
2.iterates the AllTables collection looking for a table whose name includes the substring "Backup".
3.iterates the AllTables collection to determine if a table is open. If it is, it prompts the user to close it.