Counting records

T

Tony Williams

I have a report which is based on a query. One of the fields in the query is
a based on a field in a table which is also used as a source for a combo box
on a form. There are 4 values, lets say Val1, Val2,Val3 and Val4. In my
report I want to count how many records have Val1, how many Val2 and so on.
I assume I use the Count() function but how do I count the number of records
that have each value of my field?
Thanks
Tony
 
M

Marshall Barton

Tony said:
I have a report which is based on a query. One of the fields in the query is
a based on a field in a table which is also used as a source for a combo box
on a form. There are 4 values, lets say Val1, Val2,Val3 and Val4. In my
report I want to count how many records have Val1, how many Val2 and so on.
I assume I use the Count() function but how do I count the number of records
that have each value of my field?


A quick and dirty way would be to use expressions like:
=Sum(IIf(thefield=val1, 1, 0))

But that is not a good approach because it imbeds a data
value in the expression. A better way is to create a Totals
type query that calculates all the totals and use the query
as the record source of a subreport.
 
G

Guest

I have lost the plot,what is a Totals Query?
If I do that I end up with 10 queries. what am I doing wrong?
 

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