Getting Combo Box to work

R

Ron

Hi,

I have a combo box on a form. I have a table which contains the firlds:
ItemName And Type
I want to populate the combo box with a list of ItemName which are of Type1 .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
(((FoodItems.Type)=[Cereals & Grain]));

Any Ideas?? TIA
 
F

fredg

Hi,

I have a combo box on a form. I have a table which contains the firlds:
ItemName And Type
I want to populate the combo box with a list of ItemName which are of Type1 .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
(((FoodItems.Type)=[Cereals & Grain]));

Any Ideas?? TIA

Is [Cereal & Grains] the name of the control on the form that displays
the value "Type1"?
If so, you need to concatenate the value into the expression.

SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
FoodItems.Type)='" & [Cereals & Grain] & "'"

The above assumes [FoodItem].Type is a Text datatype.

However, if in fact it is a Number datatype, then use:
SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
FoodItems.Type)=" & [Cereals & Grain]

Make sure the value shown in [Cereal & Grain] is the same datatype as
[Type].

NOTE: Type is a reserved Access/VBA/Jet word (it's a Field property)
and should not be used as a field name.

For a more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 
R

Ron

Let me take away the ambiguity of using the reserved word "Type"

I have a combo box on a form. I have a table, FoodItems which contains the
firlds:
ItemName And FoodGroup
I want to populate the combo box with a list of ItemName which are of a
speciic FoodGroup .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems WHERE
(((FoodItems.FoodGroup)=[Cereals & Grain]));

Just to clear it up further FoodGroup has in it Breads, Cereal & Grains,
Veggies, Fruit, Fruit Juice, etc. There are many foods in each FoodGroup.
All I want are the foods that are in "Cereal & Grains".

I hope this cleared up the questions you may have had

TIA


--
Ron


fredg said:
Hi,

I have a combo box on a form. I have a table which contains the firlds:
ItemName And Type
I want to populate the combo box with a list of ItemName which are of Type1 .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
(((FoodItems.Type)=[Cereals & Grain]));

Any Ideas?? TIA

Is [Cereal & Grains] the name of the control on the form that displays
the value "Type1"?
If so, you need to concatenate the value into the expression.

SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
FoodItems.Type)='" & [Cereals & Grain] & "'"

The above assumes [FoodItem].Type is a Text datatype.

However, if in fact it is a Number datatype, then use:
SELECT FoodItems.ItemName, FoodItems.Type FROM FoodItems WHERE
FoodItems.Type)=" & [Cereals & Grain]

Make sure the value shown in [Cereal & Grain] is the same datatype as
[Type].

NOTE: Type is a reserved Access/VBA/Jet word (it's a Field property)
and should not be used as a field name.

For a more complete list of reserved words, see:
http://www.allenbrowne.com/AppIssueBadWord.html
 
F

fredg

Let me take away the ambiguity of using the reserved word "Type"

I have a combo box on a form. I have a table, FoodItems which contains the
firlds:
ItemName And FoodGroup
I want to populate the combo box with a list of ItemName which are of a
speciic FoodGroup .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems WHERE
(((FoodItems.FoodGroup)=[Cereals & Grain]));

Just to clear it up further FoodGroup has in it Breads, Cereal & Grains,
Veggies, Fruit, Fruit Juice, etc. There are many foods in each FoodGroup.
All I want are the foods that are in "Cereal & Grains".

I hope this cleared up the questions you may have had

TIA

So there is no FIELD named Cereal & Grains?
By placing Cereal & Grains within brackets that is Access way of
denoting a Field Name.

WHERE FoodItems.FoodGroup)="Cereals & Grain";

By placing Cereal & Grains within quotes, Access will treat it as
Text.
 
R

Ron

--
Ron


fredg said:
Let me take away the ambiguity of using the reserved word "Type"

I have a combo box on a form. I have a table, FoodItems which contains the
firlds:
ItemName And FoodGroup
I want to populate the combo box with a list of ItemName which are of a
speciic FoodGroup .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems WHERE
(((FoodItems.FoodGroup)=[Cereals & Grain]));

Just to clear it up further FoodGroup has in it Breads, Cereal & Grains,
Veggies, Fruit, Fruit Juice, etc. There are many foods in each FoodGroup.
All I want are the foods that are in "Cereal & Grains".

I hope this cleared up the questions you may have had

TIA

So there is no FIELD named Cereal & Grains?
By placing Cereal & Grains within brackets that is Access way of
denoting a Field Name.

WHERE FoodItems.FoodGroup)="Cereals & Grain";

By placing Cereal & Grains within quotes, Access will treat it as
Text.
 
R

Ron

I put the following:

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.
TIA
--
Ron


Ron said:
--
Ron


fredg said:
Let me take away the ambiguity of using the reserved word "Type"

I have a combo box on a form. I have a table, FoodItems which contains the
firlds:
ItemName And FoodGroup
I want to populate the combo box with a list of ItemName which are of a
speciic FoodGroup .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems WHERE
(((FoodItems.FoodGroup)=[Cereals & Grain]));

Just to clear it up further FoodGroup has in it Breads, Cereal & Grains,
Veggies, Fruit, Fruit Juice, etc. There are many foods in each FoodGroup.
All I want are the foods that are in "Cereal & Grains".

I hope this cleared up the questions you may have had

TIA

So there is no FIELD named Cereal & Grains?
By placing Cereal & Grains within brackets that is Access way of
denoting a Field Name.

WHERE FoodItems.FoodGroup)="Cereals & Grain";

By placing Cereal & Grains within quotes, Access will treat it as
Text.
 
R

Ron

Ronought I would let you know the problem was that the Cereal & Grains had
to be enclosed in single quotes not double quotes . . . so 'Cereal & Grains'
worked fine

THANKS FOR ALL OF YOUR HELP

rON
--
Ron


Ron said:
I put the following:

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.
TIA
--
Ron


Ron said:
--
Ron


fredg said:
On Mon, 10 Dec 2007 08:18:00 -0800, Ron wrote:

Let me take away the ambiguity of using the reserved word "Type"

I have a combo box on a form. I have a table, FoodItems which contains the
firlds:
ItemName And FoodGroup
I want to populate the combo box with a list of ItemName which are of a
speciic FoodGroup .

I Made a Select Statement:
SELECT FoodItems.ItemName, FoodItems.FoodGroup FROM FoodItems WHERE
(((FoodItems.FoodGroup)=[Cereals & Grain]));

Just to clear it up further FoodGroup has in it Breads, Cereal & Grains,
Veggies, Fruit, Fruit Juice, etc. There are many foods in each FoodGroup.
All I want are the foods that are in "Cereal & Grains".

I hope this cleared up the questions you may have had

TIA

So there is no FIELD named Cereal & Grains?
By placing Cereal & Grains within brackets that is Access way of
denoting a Field Name.

WHERE FoodItems.FoodGroup)="Cereals & Grain";

By placing Cereal & Grains within quotes, Access will treat it as
Text.
 

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