How do i do criteria on a drop down box

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

ive made a drop box with all car makes and now i want to make a model drop
box so when you select you make (Ford for example) when youwent to choose the
model it would have all fords models.
 
Dear Grant:

That sounds right to me.

This is sometimes called "drill down" or "cascading combo boxes".

There are two ways I can suggest to do this.

1. On the click event of the Makes combo box, write the SQL for the Models
combo box so it filters for the selected model.

2. Have the query for the Models reference the Makes combo box so it
filters similarly.

This presumes a proper data structure, which you did not discuss.

A problem arises if a make and model have already been selected, and the
make is subsequently changed. This would almost certainly give you a
make/model combination that is invalid. The click event of the Make combo
box should set the value of the Model combo box to null.

In some circumstances, other than make/model, it is possible the lower level
combo (your model) could have the same values for multiple cases of the
value in the primary level combo box. This would be like having Pinto for
both Ford and Chevy. Probably won't happen for automobiles, but does happen
in many other cases. In this case, I usually check whether the lower level
combo value is valid for the new primary level combo's value, and null it
only if it doesn't exist.

That is, I hope, a modest primmer on how this can be done.

Tom Ellison
 
Back
Top