iterates the AllTables collection to determine if a table is open. If it is, it prompts the user to close it. : AllTables « Access « VBA / Excel / Access / Word






iterates the AllTables collection to determine if a table is open. If it is, it prompts the user to close it.

 
Public Sub CloseTables()

    Dim tbls As AllTables
    Dim tbl As Variant
    
    Set tbls = Access.Application.CurrentData.AllTables
    For Each tbl In tbls
       If tbl.IsLoaded Then
          If vbYes = MsgBox("Close " & tbl.Name & "?") Then
             DoCmd.Close acTable, tbl.Name, acSavePrompt
          End If
       End If
    Next

End Sub

 








Related examples in the same category

1.Delete backup tables
2.iterates the AllTables collection, opens each nonsystem table, prints its structure, and then closes the open table.
3.iterates the AllTables collection looking for a table whose name includes the substring "Backup".