S
SusanV
Hi all,
I have the following sub which works fine to the immediate window, but now I
need to actually DO something with it <grin>. I'd like to populate a listbox
so that users can select the tables they would like to use, but I can't seem
to wrap my head around how to go about it - do I need to dump it into a temp
table then use that as my source or can this be done in a more direct
fashion?
Thanks in advance!
Susan
code:
''''''''''''''''''''''''''''''''''''''''
Private Sub btnGetTableList_Click()
Dim cnx As ADODB.Connection
Dim catDB As ADOX.Catalog
Dim tblList As ADOX.Table
Dim strDBPath As String
Set cnx = CurrentProject.Connection
Set catDB = New ADOX.Catalog
strDBPath = "E:\PMO_Gen\dev\"
catDB.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source= '" & strDBPath & "Pivot_Concat.mdb';"
For Each tblList In catDB.Tables
If tblList.Type = "TABLE" Then
Debug.Print tblList.Name & vbTab & tblList.Type
End If
Next
Set catDB = Nothing
cnx.Close
End Sub
''''''''''''''''''''''''''''''''''''''''
I have the following sub which works fine to the immediate window, but now I
need to actually DO something with it <grin>. I'd like to populate a listbox
so that users can select the tables they would like to use, but I can't seem
to wrap my head around how to go about it - do I need to dump it into a temp
table then use that as my source or can this be done in a more direct
fashion?
Thanks in advance!
Susan
code:
''''''''''''''''''''''''''''''''''''''''
Private Sub btnGetTableList_Click()
Dim cnx As ADODB.Connection
Dim catDB As ADOX.Catalog
Dim tblList As ADOX.Table
Dim strDBPath As String
Set cnx = CurrentProject.Connection
Set catDB = New ADOX.Catalog
strDBPath = "E:\PMO_Gen\dev\"
catDB.ActiveConnection = "Provider='Microsoft.Jet.OLEDB.4.0';" & _
"Data Source= '" & strDBPath & "Pivot_Concat.mdb';"
For Each tblList In catDB.Tables
If tblList.Type = "TABLE" Then
Debug.Print tblList.Name & vbTab & tblList.Type
End If
Next
Set catDB = Nothing
cnx.Close
End Sub
''''''''''''''''''''''''''''''''''''''''