Record Counts

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
 
N

Neil

Look into the DCount function (found in the help files). An example is as
follows:

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

HTH,

Neil.
 
M

Marshall Barton

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).
 

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