To count the number of groups on a report:
- Add a control to the header or footer of the group to be counted and name it
something like txtGroupCount. Make the control invisible, set its control source to =1,
and set its Running Sum property to Over All. This effectively generates a running count
of the number of groups.
- In the report footer, add a control with a Control Source of =[txtGroupCount]. This
displays the value of txtGroupCount as of the last group that occurs in the report at
which time it is equal to the number of groups in the report.
Note that the group count can only be displayed in the report footer (not the header)
since that is the only point at which txtGroupCount contains a value equal to the total
number of groups.
This technique can be modified to show the number of groups within the group
immediately surrounding the group to be counted by setting the Running Sum property of the
first control to Over Group, and placing the second control in the surrounding group's
footer instead of the report footer.