Counting values in a query field

  • Thread starter Thread starter Bill
  • Start date Start date
B

Bill

I have a field in a query that contains the values 1
through 5. I am attempting to display the total # of '5'
values in the field using a text box in a report. I
tried using the "=count" expression, but it will only
give me the total number of non-blank records. Does
anyone know the correct syntax that will give me the
number of records containing the value "5"?

Thanks
Bill
 
You can use an expression like:
=Sum(Abs([YourField]=5))
This assumes YourField is numeric. You can combine expressions such as
adding a condition where Gender is "F"
=Sum( Abs( [YourField]=5 AND [Gender]="F" ) )
If you want to "count" the values where YourField is either 3 or 5:
=Sum( Abs([YourField]=5 OR [YourField]=3) )
 
Worked like a charm. Thanks much
-----Original Message-----
You can use an expression like:
=Sum(Abs([YourField]=5))
This assumes YourField is numeric. You can combine expressions such as
adding a condition where Gender is "F"
=Sum( Abs( [YourField]=5 AND [Gender]="F" ) )
If you want to "count" the values where YourField is either 3 or 5:
=Sum( Abs([YourField]=5 OR [YourField]=3) )

--
Duane Hookom
Microsoft Access MVP
Please direct any questions to News Groups


Bill said:
I have a field in a query that contains the values 1
through 5. I am attempting to display the total # of '5'
values in the field using a text box in a report. I
tried using the "=count" expression, but it will only
give me the total number of non-blank records. Does
anyone know the correct syntax that will give me the
number of records containing the value "5"?

Thanks
Bill


.
 
Back
Top