Counting records

  • Thread starter Thread starter Tony Williams
  • Start date Start date
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
 
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.
 
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?
 
Back
Top