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!

Problem sith shared variables and WhileReadingRecords

Status
Not open for further replies.

syntax926

Vendor
Nov 18, 2003
6
0
0
US
I have a dataset in which I am trying to add a simulated sequence number by adding a formula which is evaluated WhileReadingRecords. In it, I am using a shared variable in which I am incrementing if it belongs to the same parent and resetting if they are different. The problem is on the first record it is always 0, even if I remove all of the loic and force it to be an arbitrary value. Does anyone know the exact evaluation order and/or a way around this problem.

TIA
 
post the formula that assigns the variable its increment, and tell us where it is sitting.

A true SHARED variable is only used with subreports, so it can't be a WHILEREADING variable.

Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Expert's Guide to Formulas / Tips and Tricks / Guide to Crystal in VB
- tek@kenhamady.com
 
sorry about that. I meant that it is a global variable (no subreports are involved and they are explicity declared global.. crystal v.9) I have two formulas in 2 detail sections.

---------------------------------------------------------
Formula 1: {@CalcSeqNo}: sitting in detail section A
WhileReadingRecords;
Global NumberVar SeqNo;
Global StringVar Category;
Global StringVar InvoiceId;
Local StringVar CurrentCategory;
Local StringVar CurrentInvoice;


if IsNull({Command.InvoiceId}) then
CurrentInvoice:= "none"
else
CurrentInvoice := {Command.InvoiceId};

//if InvoiceId <> CurrentInvoice then
// SeqNo:= 1
//else

SeqNo := 1;
//se
// SeqNo:= SeqNo + 1;

INvoiceId := CurrentInvoice;

---------------------------------------------------------
Formula 2: {@SeqNo}: sitting in detail section B
WhileReadingRecords;
Global NumberVar SeqNo;
SeqNo;
-----------------------------------------------------------

As you can see in my code, I have even commented out all logic and assigned SeqNo:= 1, but that {@SeqNo} still came evaluated to 0.

Thanks,
Roland Whitley
 
I think I figurred it out, changing evaluation time to use for formula 2 to EvaluateAfter (formula1) rather than WhileReadingRecords seem to do the trick.
 
yes...you did not indicate that both formulas are located in the same section.

There is no inherent problem with using &quot;WhilePrintingRecords&quot; I do that as a standard practise unless grouping or summary operations are involved.

But when the value of one formula depends on another in the same section then &quot;WhilePrintingRecords&quot; in the first formula triggers the appropriate timing and &quot;EvaluateAfter()&quot; keeps the rest of the formulas in order.

Jim Broadbent

The quality of the answer is directly proportional to the quality of the problem statement!
 
I needed the value for a grouping criteria, so it had to be done WhileReadingRecords;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top