Hello,
I am having difficulty populating the fields into a list box? I know how to populate the records from a field into a list box, but not the fields.
Thanks
I really don't understand what you mean by populating records into a listbox. Why should someone populate full records into a list box?
a list box is a box where you dropdown and you have a choice either to query something by the selection you highlghted.
or to insert certain values into a field in a table. You can limit that the values in the list box to only the ones you typed in. To have the values based on a query from a Table you would use usually a Combo Box.
You need to make sure if you are really refering to a list box and what do you want to do.
read up in the help of Access what are the differences between a combo and list boxes.
Combo boxes if you click on it, they usually work with a wizard and will ask which field or fields you want to query and if you wany to bind it to a certain field in your table.
Here is some code to read the tables and columns collection in the catalog.
Function JetSecurity3()
'-- set reference to ADOX library
'- Microsoft ADO Ext. 2.6 for DDL and Security
'-- Microsoft ActiveX data objects 2.6 library also needed for ADO
Dim cg As New ADOX.Catalog
Set cg.ActiveConnection = CurrentProject.Connection
Dim cl As ADOX.Column, tb As ADOX.Table
Set tb = cg.Tables("test"
Debug.Print "Tables = "; tb.Name
''For Each tb In cg.Tables
'' Debug.Print "Tables = "; tb.Name
For Each cl In tb.Columns
Debug.Print " Column = "; cl.Name
Next
''Next
End Function
If the length of all column names is under 2048 characters then you could concatenate all the names comma separated and put them in a list which would be the list source of the listbox. Post back if you need a more inclusive solution.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.