How can i generate a list of all the tables of a MSAccess database that i am selecting through a common dialogbox?Thanks in advance.
Printable View
How can i generate a list of all the tables of a MSAccess database that i am selecting through a common dialogbox?Thanks in advance.
One way of doing this is to execute SQl
sSQL = "Select Name from MSysObjects where Type = 1"
rs.OPen sSQl, adOpenDynamic, adLockOptimistic
and then you can enter this for example to a listbox
do while not rs.eof
lst.AddItem rs!Name
rs.movenext
Loop
Iouri Boutchkine
[email protected]
Using ADOX
Sub ListTables()
Dim cat As New ADOX.Catalog
Dim tbl As ADOX.Table
'References : Microsoft ADO Ext 2.1 or DDL and Security
' Open the catalog
cat.ActiveConnection = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:\nwind.mdb;"
' Loop through the tables in the database and print their name
For Each tbl In cat.Tables
If tbl.Type <> "VIEW" Then Debug.Print tbl.Name
'not to see system tables If Left$(tbl.Name, 4) <> "MSys" Then Debug.Print tbl.Name
Next
End Sub
Iouri Boutchkine
[email protected]