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 do you get round the running totals using shared variables issue? 1

Status
Not open for further replies.

jupiter8

Programmer
Nov 22, 2002
72
GB
I understand that you can not perform a running total on a calculation that uses a shared variable.

I am using Crystal Report 8.5 and I need to pass in a value from the main report to the subreport, use it in a calculation and then add up the total of the column (conditionally).

A running total would allow this, but I can not select the formula field as it does not appear in the list.

I guess there must be a workround, any ideas?
 
Here is one way using formulas:

Define @NumsAccum as follows and place in detail line

Global NumberVar Group1Value;
Global NumberVar Group2Value;
Global NumberVar Group3Value;
Local NumberVar locValue;
locValue := Some Calculation
Group1Value := Group1Value + locValue;
Group2Value := Group2Value + locValue;
Group3Value := Group3Value + locValue;
ReportValue := ReportValue + locValue;
locValue; // In case it needs to display on your detail line

Define @NumsGroupX as follows and place in their respective footers - I zero them out as well to save a reset variable

Global NumberVar Group1Value;
Local NumberVar locValue := Group1Value;
Group1Value := 0; // Reset group total
locValue; // Display group total

Define @NumsReport as follows and place in the report footer

Global NumberVar ReportValue;
Local NumberVar locValue := ReportValue;
ReportValue := 0; // Reset group total
locValue; // Display group total

It is pretty ugly but it works. Good Luck!

Have a great day!

j2consulting@yahoo.com
 
Thanks, Ive just been playing with something very similar to this. I don't mind ugly just as long as works.

Thanks once again
 
You may want to add WhilePrintingRecords; as the first line of each of the above. Sometimes it won't print right without it. Sorry if I caused you any grief over my oversight.

One of the things that drives me nuts about CR 8.5 is that there is no way to search for Local or Global variables outside of opening things up and looking at them.

One of the techniques I use to keep track of them is to change the background color of any object referencing a Local or Global variable. That way I can find them at a glance when I need to change something.

To avoid an impact on my reports, I conditionally set the background color of those objects as follows:

WhilePrintingRecords;
White

Have a great day!

j2consulting@yahoo.com
 
I had already done so.
That's a very useful tip about using background colours.

There are so many things that drive me nuts about crystal I don't know where to start. I only do odd reports now and then, so I'm no expert, however most of the reports are very complex and contain many subreports.

I have made the mistake of using crystal enterprise and calling reports via the URL and now suffer from session timeouts because crystal uses too many cookies. I know the only solution is to use crystal reports on the server (but its not installed) and call reports directly via ASP. If only crystal could write a manual on how to install their product and which components you need to which purposes, or better still have just one installation that covers everything... don't suppose it will ever happen though.
 
Have you tried passing the value to the Subreport in a parameter?
Depending upon what you are doing, this may work for you.
Create a parameter in the subreport. Make it numeric.
Your main report is likely using a formula to create some calculation. Make sure it's a 1st pass formula.
Link this formula to the parameter that you created.

I don't have access to CR at the moment, so I can't verify this, but I think it'll work for you.
HTH


Bob Suruncle
 
I have it all working now, but thanks for the tip, I didn't realise you could pass in variables in that way as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top