How to update a combobox' controlsource depending on another combo

M

mrnatcc

Hi,

I have a form with alot of comboboxes, and one of these have to have
different choices depending on one of the other comboboxes.

Basically i have a table called "Category", and one called "data". The
"data" table stores all the records, and the other tables are just choices in
my comboboxes in my form.

Category table:
1
2
3
4



What i want to achieve is to have the combobox called "categoryunder"'s
control source to be "category_1" if ie. Category is chosen to be "1".

categoryunder's control source should be "category_2" if Category is set to
"2" etc.

I have tables called "category_1", "category_2" etc.


I have tried the following code, which is pretty much equal to my vba skills
;)


Private Sub Category_AfterUpdate()
If Me.Category = "OPUS" Then Me.categoryunder.ControlSource = "category_opus"
End Sub

I hope you can help.

And i have looked through all threads on searches like controlsource and
afterupdate etc. I've done my best not to disturb you ;)

-- All i found was a kind of filter updates (querys etc).

Thanks in advance.
Morten
 
M

Maurice

Hmm, you can do this by using two queries. The first query is the source for
the first combobox (no parameter set). The second query is the source for the
second combobox where you place the criteria being the output of the first
combobox.

second query criteriareference : forms!formname!comboname
In the after update of the first combo you have to add: me.combo2.requery

this wil make the second combo filtered directly

Maurice
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top