Combo boxes

Haahz

Registered User.
Local time
Today, 13:37
Joined
Feb 9, 2009
Messages
11
Right I've spent hours and hours looking how to create a cascading combo box. I've downloaded many examples of them, but I cannot get my head around the way they work. I've got a database and I need to create a cascading combo box, I've got a combo box with Car Make this lists all Car Makes for example Ford. I need a cascading combo box called Car Model so when I click say Ford in the combo box I have a list of all Ford model cars for example Escort. I've looked through many tutorials but I'm still stumped. Would anyone be kind enough to help me. By giving me a step by step basic guide on how to do this.

Thanks a lot.

Haahz.
 
This a repeat question so se at my samplebase it show both a cascade from a normalized table setup and one from a de-normalized table setup.

JR
 

Attachments

You have to have a table with two fields, CarMake and CarModel. This table will supply data to both comboboxes.

With both comboboxes Row Source Type set to Query/Table:

Select the first combobox. Goto Properties - Data. In the Row Source Property enter

SELECT DISTINCT CarTable.CarMake FROM CarTable ORDER BY [CarMake];

Then for the first comobox's AfterUpdate Event:

Code:
Private Sub cboCarMake_AfterUpdate()
cboCarModel.RowSource = _
"Select Distinct CarTable.CarModel " & _
    "FROM CarTable " & _
    "WHERE CarTable.CarMake = '" & cboCarMake.Value & "' " & _
    "ORDER BY CarTable.CarModel;"
cboCarModel = ""
End Sub

You have to replace cboCarMake, cboCarModel and CarTable with the actual names of your comboboxes and table.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom