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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Populate listbox from another list box

Status
Not open for further replies.

bangsmic

Technical User
Oct 22, 2001
29
0
0
US
I have 2 list boxes: lstMake & lstModel

lstCatagory is populated from a query, qryMake
Lets say that in this query/list box I have selections of: Ford, Chevy, and Dodge. If I choose Ford in lstMake I want only Ford models to appear in the second list box (lstModel). I have other queries set up to do this already, Ex: qryFord, qryChevy, etc.

The question is, how to populate lstModel with the appropriate query based upon the choosen selection in lstMake.
 
Have an advanced search on Cascading ComboBox.. Same applies to listboxes..
regards

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
here is an faq702-4289

Zameer Abdulla
[sub]Jack of Visual Basic Programming, Master in Dining & Sleeping[/sub]
Visit Me
 
How are ya bangsmic . . . . .

Try this in the [blue]AfterUpdate Event[/blue] of the listbox ([blue]you![/blue] substitute proper names in [purple]purple[/purple]):
Code:
[blue]   Dim Cat As String, prp As Property
   
   Set prp = Me!lstModel.Properties("RowSource")
   Cat = Me!lstMake.Column(1)
   
   If Cat = "Ford" Then
      prp = "[purple][b]FordQueryName[/b][/purple]"
   ElseIf Cat = "Chevy" Then
      prp = "[purple][b]ChevyQueryName[/b][/purple]"
   ElseIf Cat = "Dodge" Then
      prp = "[purple][b]DodgeQueryName[/b][/purple]"
   End If

   Set prp = Nothing[/blue]

Calvin.gif
See Ya! . . . . . .
 
Get a Invalid use of Null error in

Cat = Me!lstMake.Column(1) line.

I see the logic in the code but don't see where the error is.
 
bangsmic . . . . .

Change:
[blue]Me!lstMake.Column(1)[/blue]
To:
[blue]Me!lstMake[/blue]

Calvin.gif
See Ya! . . . . . .
 
Hm - this is very static, what do you do when there's another car entering the system, create a new query?

Why not have a look at the faq pointed to by ZmrAbdulla, which is a "one query does it all" approach....

Roy-Vidar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top