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!

SubReports Linkage

Status
Not open for further replies.

Steve95

MIS
Nov 3, 2004
265
US
Hi All

I have a report which has 2 parameters (start date and an end date), the main report contains a subreport which is linked by these parameters.

The problem: their is a "sum of" data type "number" value which I need to bring to the main report and then use that value to do a calcualtion with a value from the main report. The value in the main report is also data type 'number'.

Does anyone know how best I can do this?

I look forward to your responses.....

Many Thanks
 
In the subreport, create a formula:

whileprintingrecords;
shared numbervar sumsub := sum({table.number});

You must place this on the subreport canvas.

Then in the main report, in a section below the one in which the subreport is executing, use another formula to do your calculation, as in:

whileprintingrecords;
shared numbervar sumsub;

sum({table.field},{table.group}) + sumsub;

If the subreport can sometimes not return a value, then you need to also have a reset formula in the main report:

whileprintingrecords;
shared numbervar sumsub := 0;

This would need to be placed in a section before the subreport executes.

-LB
 
Thanks for the above but I am abit confused as the one of fields ie the new formula containing the running total as describled above, how can I get that to show in the main report so that I can do the calculation?
 
and when you say canvas do you mean 'details' section?
 
In the subreport, your formula should look like the following, and because it is a running total, it should be placed in the subreport report footer:

whileprintingrecords;
shared numbervar sumsub := {#yourrunningtotal};

If you want to display the running total in the main report, you can use a formula like the following, but it must be placed in a section below the one in which the subreport is executing:

whileprintingrecords;
shared numbervar sumsub;

If you just want to use the figure for calculation, then you only need to reference it in a formula, as in:

whileprintingrecords;
shared numbervar sumsub;
sum({table.field},{table.group}) + sumsub;

You should use the reset formula as I mentioned earlier, also.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top