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

Calculating Totals with SubReports 1

Status
Not open for further replies.

mmemon

Programmer
Nov 21, 2002
46
0
0
US
Hello Everyone,

I have a report that has 3 subreports in it. What I would like to do is take the totals of the report and display it on the main and also I need to calculate the average of the totals in the 3 subreports and display it on the main. What is the easiest way to handle this? Any thoughts will be appreciated. Thank you..

Michele
 
The exact syntax depends on the version of Crystal you are using. Assuming you are using a more recent version;
Create formulas in your subreports to store the subreport totals into variables e.g.

Shared NumberVar subreport1 := 1000;

Do this for each subreport, then retrieve the values from the variables in the main report e.g.

Shared NumberVar subreport1;

Hope this helps.

 
You can create shared variables and pass the values to the main report, however you can only display them in the Main after the subreport is executed (same section or after).

In the subreport create and assign the values:

whileprintingrecords;
shared numbervar Total1 := Sum ({Orders.Order Amount1}, {@groupme})
shared numbervar Total2 := Sum ({Orders.Order Amount2}, {@groupme})
shared numbervar Total3 := Sum ({Orders.Order Amount3}, {@groupme})


In the Main report use the variables:
whileprintingrecords;
shared numbervar Total1;
Total1

Would display the value of Total1.

You can add the three values and divide by 3 either within the subreport or back in the main report to get the average.

Hope this helps.

-k kai@informeddatadecisions.com
 
Hello,

I'm using Crystal 8.5. I attempted to follow the above instructions. I made a formula in my subreport:

@YTDTotalTax
whileprintingrecords;
Shared NumberVar YTDTtlTaxes := Sum ({prtaxes.ytdamount})

...then called the variable from a formula in my main report:

@TotalTaxes
whileprintingrecords;
Shared NumberVar YTDTtlTaxes;
YTDTtlTaxes

It displays a zero in the main report and the correct total ($164.46) in the subreport. Any ideas what I'm doing wrong?

Thanks for your help.

gricks

 
Never mind! Got my answer from another post that took place the next day that was the exact same question as mine.

gricks

 
I am trying to create a running total in a main report from a variable that is coming from a subreport. I am not having any luck. Can someone give me a clue???

Peggy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top