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 IamaSherpa 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 total of subreport's variable values in groupheader

Status
Not open for further replies.

morsu

Technical User
Sep 13, 2012
3
FI
Crystal Reports 11 R2

I have variable values from subreport in the main report and I want to display total of these values in group header. Is there a way to do that? I couldn't use cross tab nor another subreport to return total value.

//@hours -- subreport formula:
whileprintingrecords;
shared currencyvar hours := sum({table.hours})

//mainreport formulas:
//@reset -- in G2 header
whileprintingrecords;
if not inrepeatedgroupheader then
(shared currencyvar hours := 0;
currencyvar mytotal := 0);

//@accum in G3 header
whileprintingrecords;
shared currencyvar hours;
currencyvar mytotal;
mytotal := mytotal + hours;

//@totalhours -- display formula
whileprintingrecords;
currencyvar mytotal;

@totalhours formula gives correct total if placed in g2 footer, but gives 0 when placed to g2 header.
 
The subreports don't run until after that Group Header has printed, so there is no way to move their values back to the Group Header. You would have to run a separate subreport in the Group Header and have it include all the same subreport values from the group below to get a total in the Group Header.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guides to Formulas, Parameters, Subreports, Cross-tabs, VB, Tips and Tricks
 
Thanks Ken! Got it work with separate subreport. Printing report is a little bit slower now with two subreports, but this doesn't matter because this report is sheduled and do calculating every night.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top