Count function

  • Thread starter Thread starter Ryan
  • Start date Start date
R

Ryan

Really new at this cannot figure out how to count
specific records in a record set. if I have 100 records
in a report I can use the count(*) to count the 100
records but if I have a field that i want to count the
number of records out of the 100 that contain a certain
value...this is what i am having problems with..

if anyone can help I would appreciate

Ryan
 
I would look at the DCount function in reports:
=DCount("[fieldname]", "Tablename", "[fieldname]
= 'ValueToCount'")
Hope this helps
Fons
 
-----Original Message-----
Really new at this cannot figure out how to count
specific records in a record set. if I have 100 records
in a report I can use the count(*) to count the 100
records but if I have a field that i want to count the
number of records out of the 100 that contain a certain
value...this is what i am having problems with..

if anyone can help I would appreciate

Ryan
.
One way would be to create an expession in the query, and
use an inline if statement like CountOfCriteria:=IIF
(Criteria is true,1,0). Then just sum the results in a
text box. Control Source of the text box would be =Sum
(CountOfCriteria).
 
Really new at this cannot figure out how to count
specific records in a record set. if I have 100 records
in a report I can use the count(*) to count the 100
records but if I have a field that i want to count the
number of records out of the 100 that contain a certain
value...this is what i am having problems with..

If you need to count only how many times a specific value occurs in your report,
you can use the "Sum()" function to do that:

=Abs(Sum([FieldName]="SomeValue"))

The "=" expression will generate a "True/False" value, which evaluates to
either -1 or 0, so the Sum() will reflect the total of "True" values as a
negative number. The "Abs()" function will convert that number to a positive
number. Use this technique as the "Control Source" for a text box for each value
you want a count for.
 
Thankyou that works great...but I cannot get it to work
with a yes/no check box is this possible.

Ryan
-----Original Message-----
Really new at this cannot figure out how to count
specific records in a record set. if I have 100 records
in a report I can use the count(*) to count the 100
records but if I have a field that i want to count the
number of records out of the 100 that contain a certain
value...this is what i am having problems with..

If you need to count only how many times a specific value occurs in your report,
you can use the "Sum()" function to do that:

=Abs(Sum([FieldName]="SomeValue"))

The "=" expression will generate a "True/False" value, which evaluates to
either -1 or 0, so the Sum() will reflect the total of "True" values as a
negative number. The "Abs()" function will convert that number to a positive
number. Use this technique as the "Control Source" for a text box for each value
you want a count for.

--
Bruce M. Thompson, Microsoft Access MVP
(e-mail address removed) (See the Access FAQ at http://www.mvps.org/access)within the newsgroups so that all might benefit.<<


.
 
Thankyou that works great...but I cannot get it to work
with a yes/no check box is this possible.

If you're trying to count the number of "Yes" values:

=Abs(Sum([YesNoFieldName]))

If you're trying to count the number of "No" values:

=Sum([YesNoFieldName] + 1)
 
Back
Top