Hi!
I have an ADO object that connect to DB.
How can I get a list of all tables that belong to this DB?
(By code)
Thank you
Printable View
Hi!
I have an ADO object that connect to DB.
How can I get a list of all tables that belong to this DB?
(By code)
Thank you
Dim i As Long
Dim db As Database
Dim AllTableDefs
Set db = DBEngine.OpenDatabase(db)
Set AllTableDefs = db.TableDefs
'list the table name,List_AccessTable is a listbox control that can listing the table name
List_AccessTable.Clear
For i = 0 To AllTableDefs.Count - 1
List_AccessTable.AddItem AllTableDefs(i).Name
Next
'del the unnecessary table
For i = 0 To List_AccessTable.ListCount - 1
If List_AccessTable.List(i) = "MSysAccessObjects" Or List_AccessTable.List(i) = "MSysACEs" Or List_AccessTable.List(i) = "MSysObjects" Or _
List_AccessTable.List(i) = "MSysQueries" Or List_AccessTable.List(i) = "MSysRelationships" Or List_AccessTable.List(i) = "MSysModules" _
Or List_AccessTable.List(i) = "MSysModules2" Then
List_AccessTable.RemoveItem (i)
i = i - 1
End If
Next i
db.Close