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!

Can totals in a subreport be carried over to the main report.

Status
Not open for further replies.

cmmrfrds

Programmer
Feb 13, 2000
4,690
US
I have a report with 2 subreports which each have totals. I would like to add the totals together for a final total on the main report. How does one get the totals from a subreport to the main report which will have a total line after the second subreport.

Thank you,
Jerry
 
If you are using a late version of CR you can use a shared variable. If you are using 6 or earlier you will use a similar method but will need to include an additional .dll with distribution. When using a shared variable you need to declare it and initialize it. You can do this in the report header and/or in group headers. To initialize create a formula field and name it Reset or something. In the editor type:

WhilePrintingRecords;

Shared NumberVar MyNumber;

MyNumber := 0;

CR is picky about syntax. When it checks, drag it to the report and/or group header.

To add the subreport total to your variable edit your subreport, create a new formula field and in the editor type

WhilePrintingRecords;

Shared NumberVar MyNumber;

MyNumber := MyNumber + {name of your subreport total field}

Drag this field to the same section that your total field appears in in the subreport.

To display this value back in the main report, again create a new formula field in the main report and name it DisplayTotal or something. In the editor type:

WhilePrintingRecords;

SharedNumberVar MyNumber;

MyNumber;

Drag it to the section you want it to appear in.

 
Thank you. As I don't want a running number between subreports, I made 2 shared variables for the column. In sub1 I made a formula for the first variable and it totals okay. In sub2 I made a formula for the second variable and it totals okay. In the main report, I tried to add the 2 sub variables together but can't seem to get it to take the formula. Does the final total need to be in a footer? I am not sure how to create that footer.
 
make sure your formulas are inserted into the main report in a section that is below that of the subreports or they will not populate. Also make sure you have inserted the original shared variable formulas into the report before trying to use them in a totalling formula. Seagate Certified RCAD Specialist.
-Bruce Thuel-Chassaigne
roadkill150@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top