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

Formulas - Order of Processing 1

Status
Not open for further replies.

phillbert

Programmer
Jul 21, 2002
2
US
Can anyone help to explain the order in which Crystal Reports 8.0.0.371 processes formulas within the Detail and Group sections?

I am using two groups within my report and need to be able to get the results from a formula that is calculated in the detail section into either the header or footer of the second group. I also want to reset the formula after it is printed in the group. Here is a very simple example:

Report Header: (initalize the variable to 100)
Formula SetIt:
numbervar a:=100;

Details Section: (add the records in group to variable)
Formula CountIt:
whilereadingrecords;
numbervar a := a+1;

Group Footer:
Formula DisplayIt: (I need the total from CountIt)
numbervar a;

Formula ResetIt: (Put it back to 100)
evaluateafter ({@displayit});
numbervar a:=100;

CountIt never gets set back to 100 by ResetIt. DisplayIt just shows 100. If I add the 'evaluateafter ({@countit});' line in DisplayIt, then countit always shows 101.

Is my problem with the order in which formulas are executed based on what section they are inserted?

Any help would be appreciated. Thanks!
 
I use 'shared' before this type of variable declaration.

I think you can accomplish the same thing using a running total and formula. Howard Hammerman,
Crystal Reports training, consulting, books, training material,support. HammerLauch program runs reports without Crystal
howard@hammerman.com
800-783-2269
 
Shared is only required if it's being passed to a subreport.

And Howard is probably correct about the Running Total, I didn't really look at what you were trying to do (still haven't), I just addressed the problem.

People seem to LOVE creating formulas with variables when a simple right click insert summary or a Running Total will suffice.

-k kai@informeddatadecisions.com
 
Phillbert,

All your problem is is that you need to change 'WhileReadingRecords' to 'WhilePrintingRecords' in your details formula. Put 'WhilePrintingRecords' at the beginning of all your formulae. Your last formula should drop 'EvaluateAfter'.

Your variables are already global. Only 'Local' and 'Shared' variables need to be explicitly declared - otherwise, all variables are 'Global' by default, so it's usually unnececessary to explicitly declare a global variable.

All the best,

Naith
 
Thank you all for responding to this post. I do appreciate everyone helping me with this problem.

Naith ... The example I gave above was used for simplicity sake. The real formulas were working with multiple date fields. I followed all of your suggestions and the report is now working!!!

Again, thanks!
Phil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top