Query with Combo Box

  • Thread starter Thread starter Ron
  • Start date Start date
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
 
Try reversing --
Control Source - ItemName
Row Source - SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems
WHERE (((FoodItems.FoodGroup)="Cereal & Grains"));
 
I did as you suggested and #Name? shows in the combo box and there is nothing
there when I dropdown the combo box.
 
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.
 
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.
 
Back
Top