Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Fill a listbox with tables & fields 1

Status
Not open for further replies.

MisterC

IS-IT--Management
Apr 19, 2001
501
US
If I establish an ADO connection to an Access database, how do I fill a listbox with all the db's tables and fields?
 
Surely someone can help me with this...
I know I can use the alltables collection to get the table names, but I also need to get the tables' field names as well. X-)
 
Guess what I did yesterday!
As you are a technical sort of chap I'll just paste my stuff in. It's not hard anyway.

Here we go

This finds the table names

Set rs = cnnnew.OpenSchema(adSchemaTables)
If Not (rs.EOF And rs.BOF) Then
Do Until rs.EOF
If UCase$(rs(3)) = "TABLE" Then
lstTables.AddItem rs(2)
End If
rs.MoveNext
Loop
End If


This finds the columns for table addresses

Set rs = cnnBasic.OpenSchema(adSchemaColumns)
If Not (rs.EOF And rs.BOF) Then
Do Until rs.EOF
If UCase$(rs(2)) = "ADDRESSES" Then
TListDestination.AddItem rs(3)
TListDestination.Indent(TListDestination.ListCount - 1) = 0
End If
rs.MoveNext
Loop
End If


I can't get it work that well for Excel tho. It seems to lump columns and sheets in together.


Peter Meachem
peter@accuflight.com
 
Thanks for the help! :) --------------
A little knowledge is a dangerous thing.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top