How do I count records based on certain criteria?

K

Kris

This is completely unchartered territory for me. How do I count
records based on certain criteria and then get that count to appear in
a report?

In my table, I'll call it Log, if Block = 1 and Nutrition = Yes then
count those records. I created a query with this criteria and it
returned a result of 2 records which is correct. Now how do I get that
number 2 into a report?
 
M

Marshall Barton

Kris said:
This is completely unchartered territory for me. How do I count
records based on certain criteria and then get that count to appear in
a report?

In my table, I'll call it Log, if Block = 1 and Nutrition = Yes then
count those records. I created a query with this criteria and it
returned a result of 2 records which is correct. Now how do I get that
number 2 into a report?


If you have a lot of these calculations to do, then create a
query that does them all and use it as the record source in
a subreport.

The query could look like:
SELECT Sum(IIf(Block = 1 And Nutrition = Yes, 1, 0),
Sum(IIf(Block = 2 And Nutrition = Yes, 1, 0),
Sum(IIf(Block = 1 And Nutrition = No, 1, 0),
. . .
FROM Log
 

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