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

Totals from SubReport

Status
Not open for further replies.

Wayne79

Programmer
Sep 8, 2005
36
US
Using CR8.5

The sub report is on the detail line of my report. It calculates a Functional_Amount based a Detail_Line_ID.

The sub report consists of a single group, Detail_Line_ID.

In the group 1 header is a reset formula
//{@reset} Group#1 Header
whileprintingrecords;
shared currencyvar OCharges := 0;
shared currencyvar grOCharges := 0;

In the group 1 footer is a formula called OCharges
//{@OCharges} Group#1 Footer
whileprintingrecords;
shared currencyvar OCharges := Sum ({ACHARGE_TLORDER.FUNCTIONAL_AMT}, {ACHARGE_TLORDER.DETAIL_LINE_ID});
shared currencyvar grOCharges := grOCharges + OCharges

All sections are supressesed except group 1 footer.

In the main report I get a listing of each Detail_Line_ID's total, which is good.

The Group#1 Footer contails the formula
//{@OtherCharges} Group#1 Footer
whileprintingrecords;
shared currencyVar grOCharges;
grOCharges

Which is displaying the last detail records contents rather than the sum of the detail_line_ID's.

Where did I screw up?
 
If the subreport doesn't have a link to the main report, then it willnever be reset.

Resetting should occur in the main report PRIOR to running the subreport, such as in a section prior to running the subreport, such as in the Group Header, then the subreport would fire in the Group Header B, and the formula resetting it fires in the Group Header A (use the right click of a section and insert section below to create additional sections.

Why are you running the report in the details section of the main report? By doing so, each detail row in the main report is rerunning the subreport, hence the last detail row of the main report will be the only value returned.

You didn't speak of requirements, rather of what you're doing and why it's wrong. You'll be better served to state what you have (show data) and what you need.

you may be able to resolve by using:

In the group 1 footer is a formula called OCharges
//{@OCharges} Group#1 Footer
whileprintingrecords;
shared currencyvar OCharges := OCharges+Sum ({ACHARGE_TLORDER.FUNCTIONAL_AMT}, {ACHARGE_TLORDER.DETAIL_LINE_ID});

You don't really need the grocharges variable.

-k
 
If you need the subreport at the detail level, then insert two more detail sections. In detail_a, place the reset formula (this belongs in the main report, not the subreport, as SV noted). In detail_b, place the subreport, and in detail_c, add another formula:

whileprintingrecords;
shared currencyvar OCharges;
numbervar addOcharges := addOcharges + Ocharges;

If this is a group calculation, then add the following to the group header of the main report:

whileprintingrecords;
numbervar addOcharges := 0;

...and add the following to the group footer:
whileprintingrecords;
numbervar addOcharges;

If you do not have a group in the main report, then add the last formula to the report footer.

-LB
 
While neither tip worked...I was able to solve the problem.

SV's request for requirements made me go back and review them. I'd fixated on a particular problem and passed over a simple one knowing it would only take seconds to implement.

One requirement was to show or suppress the details.

By fixating on the thornier problem of getting the other charges and fuels surcharges I over complicated the problem by thinking I needed sub reports.

All I need was a couple of formula's in the details section to segregate the charges in to their respective columns. A parameter and formula to hide the details on command solved all the problems and the report is complete.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top