Opens a table in the current database.
DoCmd.OpenTable TableName[, View][, DataMode]
with the following parameters:
TableName
A String indicating the name of the table in the current database to open.
View
One of the following members of the AcView enumeration: acViewDesign (design view), acViewNormal (datasheet view, the default), and acViewPreview (print preview).
DataMode
A member of the AcOpenDataMode enumeration for tables opened in acNormal view. Possible values are acAdd, acEdit (the default), and acReadOnly.
The example code iterates the AllTables collection, opens each nonsystem table, prints its structure, and then closes the open table.
Public Sub PrintTableStructures()
Dim tbl As Variant
For Each tbl In CurrentData.AllTables
If InStr(1, tbl.Name, "MSys", vbBinaryCompare) = 0 Then
DoCmd.OpenTable tbl.Name, acViewDesign
If MsgBox("Print table structure?", _
vbQuestion Or vbYesNoCancel, _
"Print Table Structure") = vbYes Then
DoCmd.PrintOut acPrintAll
End If
DoCmd.Close acTable, tbl.Name, acSaveNo
End If
Next
End Sub
You can iterate the tables in the current database by using the CurrentData.AllTables collection. It includes system tables whose names begin with MSys…, however.