Full Version: Populate a List Box with Table Names & Table data
UtterAccess Forums > Microsoft® Access > Access Forms
hewstone999
I have 2 questions/problems:
. I want to populate a list box with all the Tables Names in my Database using VBA.
2. I also want to create another List Box or Grid (or any thing that will show table data) that when i have select a Table Name (See above (1)) it will show all the data in that table in the List Box. Was thinking some kind of SQL using vba to populate the list box?
Any ideas or help will be much appreciated
Richard
Larry Larsen
Hi
Welcome to Utter Access Forums..

Check out the attached example demo..(for option 1)

HTH's
thumbup.gif
hewstone999
Thanks for your help, works like a treat thanks.gif
Any information on how I can create (option 2)?
Larry Larsen
Hi Richard
Very much a standard query behind the second listbox should allow you populate the control, you just need to find a way of using the variable that indicates which table to use..
g:
CODE
Dim mysql As String
Dim tName As String
tName = ListBoxSelection
mysql = "Select * From [" & tName & "]"
Me.SecondListBox.RowSource = mysql

Total air code and will need some reviewing.. but should give an idea..

thumbup.gif
hewstone999
The code works fine, thanks.gif
Thanks for your help on this.
Kind Regards
Richard
Larry Larsen
Hi
You're welcome..
thumbup.gif
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.