Pass option box selection to combo box query criteria

M

m stroup

I have an option box with options 1-4.
I have a combo box with data based on a query.
I would like to have the option box selection limit the selections on the
combo box.
Any help is appreciated.
 
M

Maurice

Give a little more info her or an example of what you are trying to achieve
then we might be able to assist you.

The way I read it now is that when you select 1 in the optionbox you want to
have only one choice in the combobox. What's the source of the combobox?
 
M

m stroup

If I select option 1 - (say team 1), I want only members of team 1 to be
displayed in the combo box. The combo box is based on a query of all members
from all teams and includes the member's names and the team.
 
J

John W. Vinson

I have an option box with options 1-4.
I have a combo box with data based on a query.
I would like to have the option box selection limit the selections on the
combo box.
Any help is appreciated.

This is a minor variant on the FAQ "conditional combo boxes".

Change the combo box's Query to reference the option group as a criterion;
e.g. if you have four values of the GroupID field, use something like

=[Forms]![YourFormName]![YourOptionGroupName]

as a criterion on GroupID. You'll also need to Requery the combo box in the
AfterUpdate event of the Option Group control.
 
M

Maurice

Ok, clear.

Your query is leading here. It should be paramatized based on the choice
made in the optionbox.

In your query you have a field indicating if a player belongs to team 1. In
that field in the query put in the criteriabox: "forms!formname!optionbox"

Now replace the 'formname' with the actual name of the form where the
optionbox is placed on. After that rename the 'optionbox' part to the actual
name of the optionbox which you have placed on the form.

Now the last part you have to do is to requery the combo when a choice is
made.
Go to designview of our form and click the properties of the optionbox. Look
for the afterupdate event and choose the ... to create an event.

In the after_update event place the following line between the sub and end
sub:

me.combobox.requery

rename the 'combobox' for the actual name of your combobox.

One final remark... the optionbox returns a numerical value. So the field in
the query should be a numerical field otherwise the combo will not return any
records.

hth
 
M

m stroup

Thanks John! As above, this works great.


--
Teach me to fish! Thanks for the help.
Pax, M


John W. Vinson said:
I have an option box with options 1-4.
I have a combo box with data based on a query.
I would like to have the option box selection limit the selections on the
combo box.
Any help is appreciated.

This is a minor variant on the FAQ "conditional combo boxes".

Change the combo box's Query to reference the option group as a criterion;
e.g. if you have four values of the GroupID field, use something like

=[Forms]![YourFormName]![YourOptionGroupName]

as a criterion on GroupID. You'll also need to Requery the combo box in the
AfterUpdate event of the Option Group control.
 

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