Combo box selection narrows next combo box choices 
Author Message
 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  
 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  
 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  
 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  
 
 [ 4 post ] 

 Relevant Pages 

1. Limit subform combo box by selection in parent combo box

2. Populate a combo box from another combo box selection

3. Combo Box and hidden text boxes upon choice

4. Combo Box and hidden text boxes upon choice

5. Can't get Combo Box selection into Text Box

6. List Box & Combo Box selection notification

7. enter data in a combo box based on value from another combo box

8. Want Access combo box to filter rowsource of another combo box

9. Populating a combo box from another combo box

10. selecting records for 2nd combo box dependant on first combo box

11. Help filling second combo box from fist combo box

12. load 2nd combo box - depend on first combo box

 

 
Powered by phpBB® Forum Software