Counting records from a subform to a grouped main form

S

Scott Albright

I have a parent report that lists records by group. That record's donation
record is listed under their name via a subreport. I want to count the
records within each grade who have a donation record listed. I am under the
impression that I should do this by counting the record in the sub form. I
have a text box in the subreports header with a control source of =Count(*).
I have a text box in the parent-form detail control source
=subreport.report.txtCounter where txtCounter is the above-mentioned text
box. The Running Sum is set to Over All. I have a text box in the grade
group footer of the parent report with control source =txtRunningCounter
where txtRunningCounter is the last-mentioned text box. I got this idea from
MVP Marshall Barton. It's not working. What am I doing incorrectly? Am I
even setting up this problem correctly? Thanks in advance for your help.
 
K

Ken Sheridan

As far as I can see from your description the only thing you are doing wrong
is setting the txtRunningCounter control's RunningSum property to 'Over All'.
It looks to me as though it should be set to 'Over Group'. This will
reinitialize the summation at the start of each Grade grouping.

The technique is a pretty standard one for this sort of thing, and I've used
it myself successfully. There are other ways however; for instance you can
look up the data directly from a table or query by calling the DCount
function in an expression as the ControlSource of a text box in the group
footer, passing the current Grade value as the criterion; or you can do as
you are at present but 'push' the value into an unbound control in the group
footer by initializing the control to zero in the group header's print event
procedure and then incrementing it by the count of rows in each subreport in
the main report's detail section's Print event procedure. The last approach
is more designed for aggregating values in page footers to give a 'page
count', however, where the control is initialized in the page header's event
procedure, and shouldn't be necessary when using a group footer. Your
current approach should be fine.

Ken Sheridan
Stafford, England
 
S

Scott Albright

That was it. Thank you very much.

Ken Sheridan said:
As far as I can see from your description the only thing you are doing wrong
is setting the txtRunningCounter control's RunningSum property to 'Over All'.
It looks to me as though it should be set to 'Over Group'. This will
reinitialize the summation at the start of each Grade grouping.

The technique is a pretty standard one for this sort of thing, and I've used
it myself successfully. There are other ways however; for instance you can
look up the data directly from a table or query by calling the DCount
function in an expression as the ControlSource of a text box in the group
footer, passing the current Grade value as the criterion; or you can do as
you are at present but 'push' the value into an unbound control in the group
footer by initializing the control to zero in the group header's print event
procedure and then incrementing it by the count of rows in each subreport in
the main report's detail section's Print event procedure. The last approach
is more designed for aggregating values in page footers to give a 'page
count', however, where the control is initialized in the page header's event
procedure, and shouldn't be necessary when using a group footer. Your
current approach should be fine.

Ken Sheridan
Stafford, England
 

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