Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to display sum on each page for a group

Status
Not open for further replies.

wrbodine

Programmer
Aug 24, 2000
302
US
Hi,

I have a field which I want to display on each page of a report (in a group header) that gives the sum of balances for every account in a specific group. This sum needs to be displayed on each page (so even on page 1 the sum for all the entire group, that goes to say page 4 will be displayed, and then page 5 will start with the new sum for the next group, etc.)

I tried using a running total field, but that adds up on each page, so page 1 only displays the total in the group heading up through that page. I can't use a simple "Sum of" field, because there's another twist in this: for each account there may be more than 1 detail line, for different bills, and the same balance will be displayed in each of these lines. So when I'm adding up the balances I only want 1 balance for each account, what the account really has, but I don't know how to display this only once, except for suppressing duplicates, which still has the value being added up.

Example:

Group header - Group 109 total 5525.00 (the number I want)
Detail -
Account 59
Bill amt. 1000.00 Balance: 5000.00
Bill amt. 2000.00 Balance: 5000.00
Bill amt. 3000.00 Balance: 5000.00

Account 2022
Bill amt. 10000.00 Balance: 25.00
Bill amt. 2923.00 Balance: 25.00

Page 2
Group header - Group 109 total 5525.00 (the desired number)
Account 5055
Bill amt. 5000.00 Balance: 500.00
Bill amt. 900.00 Balance: 500.00

Page 3
Group header - Group 272 total 9000.00 (the new number for a new group)
Account 927
Bill amt. 72.00 Balance: 5000.00
Bill amt. 92.00 Balance: 5000.00

Account 555
Bill amt. 900.00 Balance: 4000.00
Bill amt. 500.00 Balance: 4000.00
Bill amt. 400.00 Balance: 4000.00

 
I believe your best choice is to insert a Linked subreport returning the required "unduplicated" sum for the current Group in "Page Header A". Pass the result via a shared variable and display in on "Page Header B".

Cheers,
- Ido CUT, Visual CUT, and DataLink Viewer:
view, e-mail, export, burst, distribute, and schedule Crystal Reports.
 
Thanks so much, Ido, for the input! I created a subreport, which is a lot like the original report, and gets the correct totals in the group footer. (BTW, I can now get the correct total on the original report in the group footer as a running sum, but don't know how to move the value up to the group header, that displays on each page.)

I'm not sure what field to link by, or how the subreport is even supposed to work. When I include it in the report and attempt to preview it or run the report, it hangs....

Anyone have any ideas for either one of these ways of getting it to work (the subreport or being able to bring up a total from the group footer and display it in the group header, that's displayed on every page (where the footer is just once at the end of the group)?
 
The total doesn't appear to be a sum of the balance, it's the sum of the distinct value, hence the use of a subreport.

Create another Group Header (right click and select insert section below), and place the Subreport into GH A.

The subreport will link via the GroupNumber field. You'll have to work out how to display the correct number since you have multiple entries, hopefully you can simplify your sum by selecting the unique Balances without worrying over the duplication in your Select.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top