Query with Combo Box

R

Ron

I have a table FoodItems with 2 Fields ItemName and FoodGroups. On my form I
want to have a combo Box show me all of the ItemName which are contained in a
specific FoodGroup.

For example I want to have all of the ItemName that are in the "Cereal &
Grain" FoodGroup. I did the following:

I Put: SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems WHERE
(((FoodItems.FoodGroup)="Cereal & Grains"));
in the Controlsource for the Combo Box. I put FoodItems in the RowSource,
and Table/Query in the RowSource Type.

Now #Name? shows up in the combo box. When I drop down the Combo Box all of
the FoodItems.ItemName show up.

What am I doing wrong??
TIA
 
K

KARL DEWEY

Try reversing --
Control Source - ItemName
Row Source - SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems
WHERE (((FoodItems.FoodGroup)="Cereal & Grains"));
 
R

Ron

I did as you suggested and #Name? shows in the combo box and there is nothing
there when I dropdown the combo box.
 
K

KARL DEWEY

I said Control Source - ItemName but that is wrong. You need to use the
field of your data table, not that of the combo box source. The table where
you are storing the records.
 
S

Skip

Ron said:
I have a table FoodItems with 2 Fields ItemName and FoodGroups. On my form
I
want to have a combo Box show me all of the ItemName which are contained
in a
specific FoodGroup.

For example I want to have all of the ItemName that are in the "Cereal &
Grain" FoodGroup. I did the following:

I Put: SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems
WHERE
(((FoodItems.FoodGroup)="Cereal & Grains"));
in the Controlsource for the Combo Box. I put FoodItems in the RowSource,
and Table/Query in the RowSource Type.

Now #Name? shows up in the combo box. When I drop down the Combo Box all
of
the FoodItems.ItemName show up.

What am I doing wrong??
TIA

If I understand you correctly, your query should be in the [Row Source]
field not the [Control Source].

It looks like you put your table name in the [Row Source] field. that would
normaly be set in the form's [Record Source] field, not in the combo-box.

Try creating the combo-box with the Combo-Box Wizard, that may be the
easiest method.
 

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