Cascading combo boxes with VALUE LIST

G

Guest

hello all I have a question on cascading combo boxes.. BUT instead of basing
these combo boxes off of a table/query they are tied to two different value
list

combo box_area has list values 1-7 which intern filters the 2nd combo
box_location
location has atleast 20 different values..

Now what i would like to do is specify in VB code is when the area combo box
has a selected # I would like the Location combo box to only display
locations that I soecified in the VB coding..
 
G

Guest

Define a value list string for each of the 7 choices for combo1 or build them
programmatically. Use the After Update event of Combo1

Private Sub Combo1_AfterUpdate()
Dim strRowSourceList as String
Select Case Me.Combo1
Case Is 1
strRowSourceList = "Choice 1; Choice 2; Choice 3"
Case Is 2
strRowSourceList = "Red; Yellow; Blue"
Case Is 3
strRowSourceList = "Oranges; Apples; Grapes"
Case Is 4
strRowSourceList = "Shoes; Hats; Gloves"
Case Is 5
strRowSourceList = "Choice 11; Choice 12; Choice 13"
Case Is 6
strRowSourceList = "Choice 21; Choice 22; Choice 23"
Case Is 7
strRowSourceList = "OatMeal; Raisin Bran; Corn Flakes"
End Select

Me.Combo2.RowSource = strRowSourceList
End Sub
 
G

Guest

Thanks Klatuu your code works perfect...

Klatuu said:
Define a value list string for each of the 7 choices for combo1 or build them
programmatically. Use the After Update event of Combo1

Private Sub Combo1_AfterUpdate()
Dim strRowSourceList as String
Select Case Me.Combo1
Case Is 1
strRowSourceList = "Choice 1; Choice 2; Choice 3"
Case Is 2
strRowSourceList = "Red; Yellow; Blue"
Case Is 3
strRowSourceList = "Oranges; Apples; Grapes"
Case Is 4
strRowSourceList = "Shoes; Hats; Gloves"
Case Is 5
strRowSourceList = "Choice 11; Choice 12; Choice 13"
Case Is 6
strRowSourceList = "Choice 21; Choice 22; Choice 23"
Case Is 7
strRowSourceList = "OatMeal; Raisin Bran; Corn Flakes"
End Select

Me.Combo2.RowSource = strRowSourceList
End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top