ACC2000: ActiveX Data Objects (ADO) Includes Queries and Views in the Tables CollectionID: Q225895
|
When you use ActiveX Data Objects (ADO) to programmatically traverse the Tables collection, you see the names of queries and views included as part of the collection.
Test for the type of object within the Tables collection. The table types can be:
Sub FindOnlyTables()
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
cat.ActiveConnection = CurrentProject.Connection
For Each tbl In cat.Tables
If tbl.Type = "TABLE" Then
If tbl.Name <> "dtproperties" Then
Debug.Print tbl.Name
End If
End If
Next tbl
End Sub
Microsoft Access 2000 uses ANSI standard SQL-92, which includes both queries and views in the Tables collection.
When you use the ADO object model to iterate through the Tables collection of an Access database, the names of queries will be included as part of the collection.
When you use the ADO object model to iterate through the Tables collection of an Access project, the names of views will be included as part of the collection.
Sub FindTables()
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
cat.ActiveConnection = CurrentProject.Connection
For Each tbl In cat.Tables
Debug.Print tbl.Name
Next tbl
End Sub
FindTables
Additional query words: prb
Keywords : kbdta
Version : WINDOWS:2000
Platform : WINDOWS
Issue type : kbprb
Last Reviewed: June 2, 1999