UtterAccess.com
X   Site Message
(Message will auto close in 2 seconds)

Welcome Guest ( Log In | Register )

 
Reply to this topicStart new topic
> Populate listbox with column names of table    
 
   
ddine
post Jul 9 2009, 08:54 AM
Post #1

UtterAccess Addict
Posts: 158



Scenario:

I have a combo box called cboSelectTable which is used to select a table from all the tables in the database. This is working.

I would like to have a list box called lboImportList which (I'm hoping) will display all the fields names and data type of the table selected in the combo box.

I know that I will need to put the code in the After Update event of the combo box.

Here is what I have so far:

CODE
Sub cboSelectTable_AfterUpdate()

Dim strSelectTable As String
Dim List1 As ListBox

strSelectTable = Me!cboSelectTable.Value

End Sub


I know it's not a lot... I don't have a lot of experience working with lists yet.

Anyone know of a good way to do this?
Go to the top of the page
 
+
AvgJoe
post Jul 9 2009, 09:23 AM
Post #2

UtterAccess Ruler
Posts: 2,042
From: West Coast, USA



Ddine,

Welcome to UtterAccess. In your database, go to Tools=>Options=>View tab. Check "System Objects". You'll now be able to see the System Objects tables. Once you find the table with the information you're looking for, create a query on that table to populate your listbox.

HTH,

AvgJoe
Go to the top of the page
 
+
theDBguy
post Jul 9 2009, 09:35 AM
Post #3

Access Wiki and Forums Moderator
Posts: 48,108
From: SoCal, USA



Hi,

Welcome to Utter Access!

As an alternative, you could try changing your code to something like:

Private Sub cboSelectTable_AfterUpdate()
Me.ListBoxName.RowSourceType = "Field List"
Me.ListBoxName.RowSource = Me.cboSelectTable
End Sub

(untested)
Hope that helps...
Go to the top of the page
 
+
ddine
post Jul 9 2009, 10:00 AM
Post #4

UtterAccess Addict
Posts: 158



Thanks both of you for the suggestions.

I've implemented the suggestion by theDbquv just because it seemed simpler. It works perfectly!
Go to the top of the page
 
+
theDBguy
post Jul 9 2009, 11:51 AM
Post #5

Access Wiki and Forums Moderator
Posts: 48,108
From: SoCal, USA



You're welcome. Joe and I are happy to help. Good luck with your project.
Go to the top of the page
 
+

Thank you for your support! Reply to this topicStart new topic

Jump To Forum:
 



RSS Go to Top  ·  Lo-Fi Version Time is now: 24th May 2013 - 08:13 PM