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!

Sum in sub reports

Status
Not open for further replies.

nb4884

IS-IT--Management
Aug 2, 2010
141
US
Hi All,

Have a question on sub-reports, not sure if I can do something like this:

FOr eg if I have 3 subreports (1,2,3), placed next to each other in a main report.

Is it possible to create a column in Main report that would be the sum of columns from 3 sub reports. Ie if I have a column A in subreport 1 , column B in subreport 2 and column C in subreport 3.

How to do A.1 + B.2+ C.3 to get a column D in main report.

Thanks

Thanks
 
To pass data back from a subreport, use a shared variable. If it was a currency value, you'd do it differently, e.g.
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved:={#TotSaved};
SumSaved
And to access it in the main report, create another formula field with
Code:
whileprintingrecords;
shared currencyvar SumSaved;
SumSaved

Note that the shared variable is only available in the section after the section which contains the subreport.

In your case it might be best to use three sets of variables and add them.

[yinyang] Madawc Williams (East Anglia, UK). Using Crystal 11.5 with SQL and Windows XP [yinyang]
 
You can pass the three amounts by setting them up as shared variables in the subreports as Madawc suggests. Then reference them in a section below the one containing the subreports:

whileprintingrecords;
shared currencyvar SumSaved;
shared currencyvar SumSavedB;
shared currencyvar SumSavedC;
SumSaved+SumSavedB+SumSavedC

If they are numbers, not currencies, use numbervar in all formulas.

You can place on the right side of the page and then format the previous section (containing the subs) to "underlay following sections" if you want the sums from the subs to display next to the overall summary.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top