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

Sum values from 2 reports

Status
Not open for further replies.

shaleen7

MIS
Jun 23, 2002
188
US
I have a subreport that I've incorprorated into a main report. Both reports have a final total value. I want to add those 2 values together. How do I accomplish this?

Thanks
 
In the subreport, create a formula that makes the subreport total a shared variable, as in:

whileprintingrecords;
shared numbervar subrpttot := sum({table.amount}); //substitute your
//subreport total calculation for sum({table.amount})

Place this on your subreport. Then in the main report, create a formula:

whileprintingrecords;
shared numbervar subrpttot;

subrpttot + sum({table.mainrptamount}); //substitute
//your main report total calculation for sum({table.mainrptamount})

Place this formula in the main report footer. Make sure the shared variable is in a section below where the subreport is executing--insert another report footer section, if necessary.

-LB
 
I keep getting an error message. The field I need to sum must be counted first.

whileprintingrecords;
shared numbervar subrpttot := sum(count({table.appno.})));
What's wrong with my formula?

Thanks.
 
You're not doing what LB suggested, hence the error.

And you haven't described the requirements, hence the limited guidance.

Read your 2 posts, they demonstrate entirely different requirements.

Try posting technical information:

Crystal version
Database used
Example data
Expected output

In this case it sounds like you have some count occuring at a group level in the subreport, and then you want to return the grand total of the count to the main report.

LB might continue to guess a bit longer, but please consider fleshing out the requirements in advance. think of creating a mini spec which describes the environment, data and output. Text descriptions often confuse more than aid.

If you have a count of a field in the sub, create a variable to sum the count seperately in a formula in the sub, and then return the sum to the main report.

-k
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top