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

How to see a grand total of a sub report field in details section? 1

Status
Not open for further replies.

munchen

Technical User
Aug 24, 2004
306
GB
I have a report that is linked to the sub report. The details section of the main report contains two fields:
Amount and Qty
To the right of these two fields I have inserted the sub report (in the details section). When i view the report all the data is correct but what i need to do is see a grand total for a sub report field and because the sub report is inserted in the details section it doesn't seem to be working.

Anyone know why? I am using crystal v 8.5 and connecting via odbc to microsoft access tables.

Here's is some sample data

Amount Qty SubAmount SubPeriod
143.60 1 365 200402
365
14.75 1 120 200403
1 775 200403
895
143.60 1 400 200402
400

As you can see instead of showing a grand total 1660(365+895+400) it just shows a total for each subperiod.

Hope someone can solve this.

Many thanks.
 
If you're returning subreport values using a Shared Variable, it will only be available in the next section.

Also subreports in detail lines are very inefficient. Is there any other method that would get the results you want?

Madawc Williams (East Anglia)
 
You need to use a shared variable to get the results you want. In the subreport, create a formula:

whileprintingrecords;
shared numbervar subamt := sum({subrpt.amt});

Place this on your subreport instead of {subrpt.amt}. Then in the main report, create a formula {@sumsharedamt}:

whileprintingrecords;
shared numbervar subamt;
numbervar grtot;

grtot := grtot + subamt;

Insert a detail_b section and place {@sumsharedamt} in this section. Then create a display formula to be placed in the report footer:

whileprintingrecords;
numbervar grtot;

This assumes that the subreport is linked to the main report on some detail field that you have not shared with us, like {table.item#}.

-LB
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top