Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

limiting contents of a combo box based on another combo box?

Status
Not open for further replies.

Data69

Technical User
Jan 24, 2003
24
US
I have an Access 2000 form. I have a combo box that allows me to select a manufacturer. Based on the manufacturer selection I only want to see the models associated with the mfg in a second combo box. I have a manufacturer table that contains mfg, mfg_id. My model table has model, mfg_id. I have entered a row source into my second combo box, but I do not get any results. here is the row source code.

SELECT model.model, model.mfg_id
FROM model
WHERE (((model.mfg_id)=[Forms]![MyForm]![cbomfg].[mfg_id]));


I have also placed an after_update code in the first combo box: mfg.requery

Can anyone tell me what I am doing wrong?

 
In the AfterUpdate of the first combo box:

Me![2ndComboBox].RowSource = "SELECT model.model, model.mfg_id FROM model WHERE model.mfg_id = " & [Forms]![MyForm]![cbomfg].Column(0) & "));"

If the mfg_id is a text field, you need single quotes:

Me![2ndComboBox].RowSource = "SELECT model.model, model.mfg_id FROM model WHERE model.mfg_id = '" & [Forms]![MyForm]![cbomfg].Column(0) & "'));"


Good luck! Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
The below after_udate entry seems to be working, but I can not see any of the models in my second combo box. The select statement in my second combobox is correct. What would cause the box not to display any text?

Me![Model].RowSource = "SELECT model.model FROM model WHERE ((model.mfg_id) = " + [Forms]![Add_Inventory]![mfg].Column(0) + ");"
 
Is model_id a text field? If so, then single quotes are needed:

Me![Model].RowSource = "SELECT model.model FROM model WHERE ((model.mfg_id) = '" + [Forms]![Add_Inventory]![mfg].Column(0) + "');"

Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Me![Model].RowSource = "SELECT model.model FROM model WHERE ((model.mfg_id) = '" & [Forms]![Add_Inventory]![mfg].Column(0) & "');"

i dont think the "+" thing works in access code

Christiaan Baes
Belgium
"What a wonderfull world" - Louis armstrong
 
Christiaan,

Actually, the + sign will work here. I have tested this!

Tony Anthony J. DeSalvo
President - ScottTech Software
"Integrating Technology with Business"
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top