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

Creating subtotals in a main report from shared variables

Status
Not open for further replies.

peggys

Technical User
Feb 21, 2003
24
US
I am trying to create subtotals in a main report from shared variables coming from subreports. The grouping is being done in the main report and I need to display the subtotals from detail records coming from subreports. Can anyone help me with this??
 
Create a formula to sum the shared variables coming back, as in:

Reset the shared variable prior to executing the subreport:

whileprintingrecords;
shared numbervar SubShare := 0;

Place this formula right after the subreport fires, it will accumulate the sharedvar:

whileprintingrecords;
global numbervar Totals;
shared numbervar SubShare;
Totals := Totals + SubShare

Use this to display the results:

whileprintingrecords;
global numbervar Totals;
Totals

-k kai@informeddatadecisions.com
 
I'm not quite sure I understand. I need to populate the variable, SubShare, with a value coming in from my database, biAmt. I then need to carry this value over into the main report for each detail record and sum it up in the group footer.

Peg
 
I thought that you already had the shared variable working in the subreport, and you were returning the values.

In the subreport add a formula:

whileprintingrecords;
shared numbervar SubShare;
Subshare =: sum(table.field} // or whatever field this is

This value will be passed back to the main, and the formulas there will provide sums of the values passed back.

It's very difficult to guess what someone has in mind from a text description of a problem, if this doesn't help you, please provide an example fo the main and subreport, example data and expected output.

-k kai@informeddatadecisions.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top