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

Runnig totals from shared variables

Status
Not open for further replies.

lovevthokie

Programmer
Oct 16, 2001
19
US
I am running CR 8.5 and VB 6 using the RDC method.
I pass in a subreport that gives me a value to display in my Main Report. I am using linking to only show a certain value on each row. I use this value in a formula to come up with a final total on each row. Now I need a grand total of that final total. How do I do this? I can't use a running total formula b/c a value used is not given until I am printing records. Please help!

Thanks in advance!
Deborah
 
Lovevthokie,

Yes, you can create a running totoal using shared variables.

Because you want a grand total - the variable does not need to be reset, therefore, created a shared numbervar MyNumbervar - and assign a value to the variable as the subreport goes through the records(MyNumbervar:={db.field})

Then in the main report - display the same shared numbervar MyNumbervar - and it will display the grand total of the subreport!

Hope this helps

paulmarr
 
paulmarr,
thank you for the helpful tips however my problem is that I pass a variable to the main report from my subreport. Then in my main report I use the subreport value in a formula(summing the shared variable with other values in each row) for each row(details section) in the main report generated. Then I need a running total of that formula's value. When I go into the running total dialog box, the formula is not an option for a running total. I may not completely understand your explanation thus the confusion!

Thanks!
 
lovevthokie,

Ok - The way Crystal Reports generates a report is where your problem lies.

Crystal uses a 3 - pass report generation system. Different aspects of a report are evaluated at different times during the 3 passes. Subreports are one of the last items to be evaluated and generated(3rd pass) - while the details of the main section start in the 1st pass. Your Running total is trying to access a value that hasn't been passed as yet. Running totals are evaluated in the 3rd pass too, but before subreports. Therefore - you will need to write a separate formula to create a manual running total instead of using the Running Total Expert.

First, write the line WhilePrintingRecords;

then create a global variable in this new manual running total formula, and assign it the formula x:= {@formula}+x

Then - create a second formula that declares and displays the global variable.

I hope this helps!

paulmarr

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top