two combo boxes (1 Viewer)

bopkid

Registered User.
Local time
Today, 16:24
Joined
Jan 27, 2003
Messages
11
I am (still) trying to make the contents of a combo box change depending on what you choose in another combo box (which is actually a value-list lookup). The data for the combo box is in a table called products, with fields cat (for category) and prod (for products), a bit like this:

Cat: Prod:
-------------------
cars mazda
cars ford
cars lada
colours red
colours blue
colours green

etc.

I have put this in the rowsource of the second combo box:

SELECT prod FROM products WHERE Cat=forms!input!category;

category is the first combo box, which (in this example) has the values cars, colours etc.

The only way you can get it to work is by selecting something in the first combo box, then going into design view, then coming out again and selecting the second combo box, for some reason.
 
R

Rich

Guest
Requery the second combo from the AfterUpdate event of the first
 

bopkid

Registered User.
Local time
Today, 16:24
Joined
Jan 27, 2003
Messages
11
I tried that, I put:

products.rowsource = SELECT prod FROM products WHERE Cat=forms!input!category;

(products is the second combo box)

but then it just said 'can't find the macro 'products'', for some reason it won't pick up the first combo box, and its really annoying
 

bopkid

Registered User.
Local time
Today, 16:24
Joined
Jan 27, 2003
Messages
11
...correction, it won't pick up the second combo box. I put that code in the afterupdate event of the first combo box.
 
R

Rich

Guest
You've put the code in the wrong place, use the code builder on the property sheet for the row source of the second combo
 

bopkid

Registered User.
Local time
Today, 16:24
Joined
Jan 27, 2003
Messages
11
why is it in the wrong place, surely it should be in the afterupdate event of the first combo box? I did use the expression builder and the property sheet.
 
R

Rich

Guest
You only need Me.My2ndCombo.Requery on the after update of the first, the row source is defined on the property sheet
 

bopkid

Registered User.
Local time
Today, 16:24
Joined
Jan 27, 2003
Messages
11
I tried putting

[Products].Requery

in the afterupdate event of the first combo box but it still keeps saying 'can't find macro 'products.'' Also tried

forms!input!products.requery

but that didn't work either, it just said can't find macro forms!input!products

Also requery doesn't appear in the expression builder
 

bopkid

Registered User.
Local time
Today, 16:24
Joined
Jan 27, 2003
Messages
11
no worry's, its sorted, just being a spanner...
 

Users who are viewing this thread

Top Bottom