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!

Grand total in main report

Status
Not open for further replies.

zsyed

MIS
Dec 25, 2011
73
CA
A report is structured as Main report withing that thre is a sub report. One main report may have multiple subreports. A sub report has a sum field. If I were to get grand total of all those sum fields from sub reports, where and how should I define a shared variable?
Hope I explaind my question correctly. Thanks in advance.

 
You need to declare it in main report header then evaluate it in each subreport footer

@increment Var
Whileprintingrecords;

shared numbervar total:=total+sum(subreportfield);

Then display in main report footer
@display var
Whileprintingrecords;

shared numbervar total;

Ian
 
Hi Ian,

I'm really a basic user in crystal reports. When you mean declare a variable in main report header, Is that some where in section expert? Appreciate your response.

Zaheer.
 
zsyed,

By Declaring the Variable in the Main Report Header, Ian is meaning that you need to create a Formula Field which will "Create/Reset" the variable prior to it's being incremented with his {@increment var} formula.

In the Group Header on the Main Report, create a Formula Field such as:
{@VariableReset_total}
Code:
[blue]WhilePrintingRecords[/blue];
[blue]Shared NumberVar total[/blue]:=0;
**Please note: I used the same variable name as Ian did in his replies, if you have used a more meaningful variable name than "total" please replace "total" in the above code with your variable name.

Cheers!

Mike
---------------------------------------------------------------
"To be alive is to revel in the moments, in the sunrise and the sunset, in the sudden and brief episodes of love and adventure,
in the hours of companionship. It is, most of all, to never be paralyzed by your fears of a future that no one can foretell."
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top