timhans
Programmer
- Jun 24, 2009
- 75
Hello,I "found" this from googling, it prints to the imediate window all the table names and there field names.
I have a need for this but for all the table names to fill a combobox and the field names per table to fill there own combobox. This past my skill level. Thanks
Sub ListTableandColumNamesADOX()
Dim Conn As New ADODB.Connection
'Open connection you want To get database objects
Conn.Provider = "MSDASQL"
Conn.Open "DSN=...;Database=...;", "UID", "PWD"
'Create catalog object
Dim Catalog As New ADOX.Catalog
Set Catalog.ActiveConnection = Conn
'List tables And columns
Dim Table As ADOX.Table, Column As ADOX.Column
For Each Table In Catalog.Tables
For Each Column In Table.Columns
Debug.Print Table.Name & ", " & Column.Name
Next
Next
End Sub
I have a need for this but for all the table names to fill a combobox and the field names per table to fill there own combobox. This past my skill level. Thanks
Sub ListTableandColumNamesADOX()
Dim Conn As New ADODB.Connection
'Open connection you want To get database objects
Conn.Provider = "MSDASQL"
Conn.Open "DSN=...;Database=...;", "UID", "PWD"
'Create catalog object
Dim Catalog As New ADOX.Catalog
Set Catalog.ActiveConnection = Conn
'List tables And columns
Dim Table As ADOX.Table, Column As ADOX.Column
For Each Table In Catalog.Tables
For Each Column In Table.Columns
Debug.Print Table.Name & ", " & Column.Name
Next
Next
End Sub