|
Combo box selection narrows next combo box choices
Author |
Message |
SBur #1 / 4
|
 Combo box selection narrows next combo box choices
I have two combo boxes. When the user makes a selection in the first combo box, there choices in the next should be limited or narrowed based on their choice in the first one. How do I do this? As an example (not what I am writing, however): First combo box is Auto Make second Auto Model. If the user chooses Honda in the first, then the only choices seen in the second are Accord, Civic, etc. If the user chooses Ford in the first then the only choices in the second are Escort, F-150, Tempo etc.
|
Sat, 14 Feb 2004 02:30:49 GMT |
|
 |
Hugh Laderma #2 / 4
|
 Combo box selection narrows next combo box choices
Assuming you're tabbing from Combo1 to Combo2, in the Combo1_Validate sub, something like Select Case Trim(Combo1.Text) Case "Honda" Combo2.Clear Combo2.Additem "Accord" Combo2.Additem "Civic" Case "Ford" Combo2.Clear Combo2.Additem "Escort" Combo2.Additem "F-150" Case Else KeepFocus=True MsgBox "Invalid Auto Make entered" End Select
Quote: > I have two combo boxes. > When the user makes a selection in the first combo box, > there choices in the next should be limited or narrowed based on their > choice in the first one. > How do I do this? > As an example (not what I am writing, however): > First combo box is Auto Make second Auto Model. > If the user chooses Honda in the first, then the only choices seen in > the second are Accord, Civic, etc. > If the user chooses Ford in the first then the only choices in the > second are Escort, F-150, Tempo etc.
|
Sat, 14 Feb 2004 03:05:27 GMT |
|
 |
SBur #3 / 4
|
 Combo box selection narrows next combo box choices
That is what I am looking for. However, Hugh, how would the code change if the combo box values were loaded in from a file (and probably into an array- possible?)? In actuality, I will probably have many choices. thanks for you input! Quote:
> Assuming you're tabbing from Combo1 to Combo2, in the Combo1_Validate sub, > something like > Select Case Trim(Combo1.Text) > Case "Honda" > Combo2.Clear > Combo2.Additem "Accord" > Combo2.Additem "Civic" > Case "Ford" > Combo2.Clear > Combo2.Additem "Escort" > Combo2.Additem "F-150" > Case Else > KeepFocus=True > MsgBox "Invalid Auto Make entered" > End Select
|
Sat, 14 Feb 2004 09:42:54 GMT |
|
 |
Hugh Laderma #4 / 4
|
 Combo box selection narrows next combo box choices
You'll have to be more specific about how the data is organized. If you have something like Array1(20) representing Combo1 categories and Array2(20,10) representing Combo2 (sub)categories, then the Validate code would look something like Dim i as Integer, j as Integer For i = 0 to 20 If Trim(Combo1.Text) = Array1(i) then Combo2.Clear For j = 0 to 10 Combo2.Additem Array2(i,j) Next j Exit Sub End If Next i 'must not have found valid Make KeepFocus=True MsgBox "Invalid Auto Make entered"
Quote: > That is what I am looking for. > However, Hugh, how would the code change if the combo box > values were loaded in from a file (and probably into an array- possible?)? > In actuality, I will probably have many choices. > thanks for you input!
Quote: > > Assuming you're tabbing from Combo1 to Combo2, in the Combo1_Validate sub, > > something like > > Select Case Trim(Combo1.Text) > > Case "Honda" > > Combo2.Clear > > Combo2.Additem "Accord" > > Combo2.Additem "Civic" > > Case "Ford" > > Combo2.Clear > > Combo2.Additem "Escort" > > Combo2.Additem "F-150" > > Case Else > > KeepFocus=True > > MsgBox "Invalid Auto Make entered" > > End Select
|
Sat, 14 Feb 2004 10:29:01 GMT |
|
|
|