Counting in Code

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I need to count the number of times records have specific statuses. I'm using
a Select Case statement in the Detail_Format event to increment a variable
for each status. I am then using that variable to print a summary in the
footer of the group.

The counts are coming out incorrect (roughly 3 times the total number of
records in the report). It appears the Detail_Format event fires more than
once per record. Is there a way to get around this? (e.g., some property that
indicates whether the Detail_Format event has already fired for the current
record)?

Thanks for any guidance.

Paco
 
Many have tried to find a way to "count" without duplicating via these
events -- but I'm not aware of any foolproof way.

Why can't you use a Sum function to count the True occurrences for when a
field's value equals the value you want to count? You can do this by putting
a textbox in the group footer like this:
=Sum(IIf[FieldName]="SomeValue",1,0)
 
That works perfectly. Thanks Ken.

Ken Snell (MVP) said:
Many have tried to find a way to "count" without duplicating via these
events -- but I'm not aware of any foolproof way.

Why can't you use a Sum function to count the True occurrences for when a
field's value equals the value you want to count? You can do this by putting
a textbox in the group footer like this:
=Sum(IIf[FieldName]="SomeValue",1,0)

--

Ken Snell
<MS ACCESS MVP>

Paco said:
I need to count the number of times records have specific statuses. I'm
using
a Select Case statement in the Detail_Format event to increment a variable
for each status. I am then using that variable to print a summary in the
footer of the group.

The counts are coming out incorrect (roughly 3 times the total number of
records in the report). It appears the Detail_Format event fires more than
once per record. Is there a way to get around this? (e.g., some property
that
indicates whether the Detail_Format event has already fired for the
current
record)?

Thanks for any guidance.

Paco
 

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

Back
Top