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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling Cumulative Total from Subreport into Main Report

Status
Not open for further replies.

sfenst

Technical User
Feb 10, 2004
3
US
Hello all! It has been a LONG time since I have worked with Shared Variables and I know I'm missing something. I have a report where I'm trying to pull manhour totals to date and event totals to date per company and then have totals for the entire project. Please see below:

GH1 Project
GH2 Company Name (suppressed)
GH3 Date (suppressed)
Details (suppressed)
GF3 Date (suppressed)
GF2 Company Name; Total Manhours/Co; Total Events/Co(subreport)
GF1 Total Manhours/Project; Total Events/Project

The event totals per company are showing correctly for each company, but when I try to to pull the totals for the project, it seems to just pull the last record. Is there something I need to reset?

Formulas are as follows:

Subreport:
WhilePrintingRecords;
NumberVar EventTotal;

EventTotal := Maximum ({Events.Events~CumulativeQtyEvent})

Main Report:
Shared NumberVar EventTotal;

Please help and let me know if you need more information. Thank you.
 
Not sure why you are using a maximum, but here is the setup:

WhilePrintingRecords;
[red]shared[/red] numberVar EventTotal;
EventTotal := ({Events.Events~CumulativeQtyEvent})

You should also add a reset in the Group #2 header, in case of a null sub:

whileprintingrecords;
shared numbervar EventTotal;
if not inrepeatedgroupheader then
EventTotal := 0;

In a Group footer #2_b section, add this formula (suppress the section):
whileprintingrecords;
shared numbervar EventTotal;
shared numbervar manhrs;//replace with your manhours variable name
numbervar sumev := sumev + EventTotal;
numbervar summanhrs := summanhrs + manhrs;

Then add a GH#1 reset:
whileprintingrecords;
numbervar sumev;
numbervar summanhrs;
if not inrepeatedgroupheader then (
sumev := 0;
summanhrs := 0
);

In the Group #1 Footer, add the final display formulas:

//{@displayev}:
whileprintingrecords;
numbervar sumev;

//{@displaymhrs}:
whileprintingrecords;
numbervar summanhrs;

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top