Click to See Complete Forum and Search --> : MSACCESS


SAKYA
July 19th, 2001, 06:50 AM
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.

Iouri
July 19th, 2001, 07:06 AM
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
iouri@hotsheet.com

Iouri
July 19th, 2001, 07:07 AM
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
iouri@hotsheet.com