Record Counts

  • Thread starter Thread starter Sammy
  • Start date Start date
S

Sammy

Hi,
I am trying to place a field on a form or report that
will count the number of records of a specific value on
the same form, in this case TRUE. So, that if each new
record's field gets a TRUE Value, it accumulates in this
field. I want to use it to record stats of several
different T/F fields for comparison.
Thanks
 
Look into the DCount function (found in the help files). An example is as
follows:

Me.MyTextBox = DCount("MyField","MyTable","MyField = " & True)

HTH,

Neil.
 
Sammy said:
I am trying to place a field on a form or report that
will count the number of records of a specific value on
the same form, in this case TRUE. So, that if each new
record's field gets a TRUE Value, it accumulates in this
field. I want to use it to record stats of several
different T/F fields for comparison.

Use a text box control with an expression like one of these
different ways to do that:

=Count(IIf(somefield, 1, Null))
or
=Sum(IIf(somefield, 1, 0))
or
=Abs(Sum(somefield))

where somefield is the name of a field in the form's record
source table/query, not a control on the form.

I think those are in decreasing order of clarity, but
increasing order of performance (usually insignificant).
 
Back
Top