Sub ListAccessTables()
''Dim cnn As ADODB.Connection
''Dim rstList As ADODB.Recordset
''Set cnn = New ADODB.Connection
' Open the connection.
''Dim strDBPath As String
''strDBPath = "c:\myaccess.accdb"
''With cnn
'' .Provider = "Microsoft.Jet.OLEDB.4.0"
'' .Open strDBPath
''End With
cnn.ConnectionString = cnn_str("Accdb")
cnn.Open
Dim rstList As ADODB.Recordset
' Open the tables schema rowset.
Set rstList = cnn.OpenSchema(adSchemaTables)
' Loop through the results and print the
' names and types in the Immediate pane.
With rstList
Do While Not .EOF
If .Fields("TABLE_TYPE") <> "VIEW" Then
If Left(.Fields("TABLE_NAME"), 4) <> "MSys" Then
Debug.Print "User: " & .Fields("TABLE_NAME") & vbTab & "Type[" & .Fields("TABLE_TYPE") & "]"
Else
Debug.Print "Msys: " & .Fields("TABLE_NAME") & vbTab & "Type[" & .Fields("TABLE_TYPE") & "]"
End If
End If
.MoveNext
Loop
End With
cnn.Close
Set cnn = Nothing
End Sub
Result:
Msys: MSysAccessStorage Type[ACCESS TABLE]
Msys: MSysACEs Type[SYSTEM TABLE]
Msys: MSysComplexColumns Type[SYSTEM TABLE]
Msys: MSysIMEXColumns Type[ACCESS TABLE]
Msys: MSysIMEXSpecs Type[ACCESS TABLE]
Msys: MSysNameMap Type[ACCESS TABLE]
Msys: MSysNavPaneGroupCategories Type[ACCESS TABLE]
Msys: MSysNavPaneGroups Type[ACCESS TABLE]
Msys: MSysNavPaneGroupToObjects Type[ACCESS TABLE]
Msys: MSysNavPaneObjectIDs Type[ACCESS TABLE]
Msys: MSysObjects Type[SYSTEM TABLE]
Msys: MSysQueries Type[SYSTEM TABLE]
Msys: MSysRelationships Type[SYSTEM TABLE]
Msys: MSysResources Type[ACCESS TABLE]
User: TableCompany Type[TABLE]
User: TableLabor Type[TABLE]
User: TableTax Type[TABLE]
User: TableTransaction Type[TABLE]
User: TableTransHeader Type[TABLE]
No comments:
Post a Comment