Expressions in Queries

G

Guest

I'm quering a table with 5 fields. In the query, I'm using the same critera
for all fields but this will only give a result if it matches all fields. I
want the query to return an answer if it matches data in any of the 5 fields,
how do I get this to happen?

Example:
Field 1: Dog
Field 2: Cat
Field 3: All
Field 4: Pig
Field 5: Cow

I want to see how many "cows" or "all" I have, so in all 5 critera field's I
have Like "Cow" or "All." This does not give any results becuase I didn't
match critera in all fields. How do I get this to work to give me an answer
by matching at least on of the fields?
 
G

Guest

In the Query Design view do the following --
Field Name: Field1 Field2 Field3
etc
Criteria: [Enter criteria]
[Enter criteria]

[Enter criteria]

[Enter criteria]
Put the [Enter criteria] for each field on a new row. You will only need to
enter the criteria once.
 
J

John Vinson

I'm quering a table with 5 fields. In the query, I'm using the same critera
for all fields but this will only give a result if it matches all fields. I
want the query to return an answer if it matches data in any of the 5 fields,
how do I get this to happen?

Example:
Field 1: Dog
Field 2: Cat
Field 3: All
Field 4: Pig
Field 5: Cow

I want to see how many "cows" or "all" I have, so in all 5 critera field's I
have Like "Cow" or "All." This does not give any results becuase I didn't
match critera in all fields. How do I get this to work to give me an answer
by matching at least on of the fields?

Use OR logic instead of AND logic. To do so, put each criterion on a
*separate line* in the query grid.

Note that the necessity to do this very strongly suggests that your
table normalization needs attention; if you have a one to many
relationship between this table and zero to five animals, you probably
should have *two tables* related one-to-many. "Fields are expensive,
records are cheap!"

John W. Vinson[MVP]
 

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