counting Unique records in a report

G

Guest

HI.....I have gone to google to check for code to count unique records in a
report.

I used the following suggestion:

A.) Use a counter in VBA to count how many times you hit the group header.
This is pretty simple. You dimension a variable: intSchoolCount as Integer
in the reports General Declarations. In the Report Header On Print Event,
add code:


intSchoolCount = 0


In the Group Header On Print event, increment the school count with code
like:


intSchoolCount = intSchoolCount + 1


Last in the section of the report that contains the control where you want
to display the total number of schools, set the control source for the
control to be empty. Then in the On Print event of that section add code:


Me!YourControlName.Value = intSchoolCount


My problem is I need to count the values by grouping. This gets me a total
count. Is there a way to count by each grouping? To use this example, say
the schools were grouped by private and public and they needed a count for
each group.

Hope this makes sense.

Thanks for your help!
 
G

Guest

Hi Steve......thank you for responding. I still have a question. I'm sorry,
I'm sure you realize you're talking to a VBA rookie. In my report I have two
group headers. In my report, I am grouping District Managers, and report the
products they have focused on in thier meetings. I basically have three
statements.

intEventCount = 0
Me!Text16.Value = intEventCount
intEventCount = intEventCount + 1

Currently I have the first two in the DM header and the third in the product
header. Now when I run the report, I of course get zeros in the event count.
What I'm wondering is, it seems I'm setting the intEventCount back to zero
before I give Text16 a value. But if I reverse it, the group headers will
have totals of the previous group. Hope this all makes sense. Thanks for
any help you can give me.

Susie
 

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