Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Variable counter in Report Post Reply Post New Topic
Author Message
LeonDT
Newbie
Newbie
Avatar

Joined: 13 Feb 2009
Location: South Africa
Online Status: Offline
Posts: 2
Quote LeonDT Replybullet Topic: Variable counter in Report
     Posted: 13 Feb 2009 at 5:14am

I am very new to the Crystal Formula programming part and I need some information.

 

I have a report that generates statements using a PeopleSoft SQL query. I have added a set of OMR markings to the report so that the a machine can fold more than one statement for the same person into a single envelope. That works fine but now I want to add a sequence check also. To do that I need to implement a counter variable that should only be initialized beginning of the report and then keep a basic count of each statement that is generated. I need to count from one to eight and then start from one again....all the way to the end of the report. What happens is that according to the value of this counter, three little stripes gets printed in specific positions as OMR markings to assist the machine to verify if there has been a problem with the sequence of the statements at the time of packaging for mailing or not.

 

I have formula fields representing the OMR markings and they are correct. I have added a "Report Header" as there was not one and inserted a formula field in it. In that formula I declare a variable like this:

Global Numbervar SeqChk;

 

Due to the fact that I need to add to this variable every time I generate a new Page header, I added another formula field on the Page Header where I want to add 1 to "SeqChk". Crystal does not seem to recognize that "SeqChk" is a global variable that has been declared in another formula and therefore,  can't add to it.  Any help in declaring/addressing variables in different formulas and how to keep track of a counter thru a whole report,  will be appreciated.

 
Regards

It's not what you know that is important in life, how you apply that knowledge is what is important.
IP IP Logged
JohnT
Groupie
Groupie
Avatar

Joined: 20 Jan 2008
Online Status: Offline
Posts: 92
Quote JohnT Replybullet Posted: 13 Feb 2009 at 11:54am
Change the formula in your page header to look like this:
 
numberVar seqchk;
Whileprintingrecords;
seqchk := seqchk + 1;
 
That should work better for you.  Note that seqchk is not global.  The code will see the global declaration for seqchk in the formula in your report header and use that memory space.  Good luck !


Edited by JohnT - 13 Feb 2009 at 12:36pm
IP IP Logged
LeonDT
Newbie
Newbie
Avatar

Joined: 13 Feb 2009
Location: South Africa
Online Status: Offline
Posts: 2
Quote LeonDT Replybullet Posted: 16 Feb 2009 at 12:25am

Thanks JonhT - I used your example and I got rid of the formula in the Report header (got rid of the report header itself also) and used the following code in a fromula (CalcSeq) on the page header:

numberVar seqchk = 0;
Whileprintingrecords;
seqchk := seqchk + 1;
if  seqchk > 8 then
 seqchk := 1;
TOTEXT(Numbervar seqchk);

I use formula fields to set the OMR in accordance with the value of "seqchk"  like this:
 
IF {@CalcSeq} = "5.00" OR
    {@CalcSeq} = "6.00" OR
    {@CalcSeq} = "7.00" OR
    {@CalcSeq} = "8.00" Then
     "__"
else
 "  ";
 
I have six of them in two bands in the left of the page header so that the machine can read the little stripes. I suppose it may not be the best and most effective way of doing it but for a monthly report, it can do the job just fine.I t works like a charm.
 
Thankyou for the help.
 
Regards
 
 
 
It's not what you know that is important in life, how you apply that knowledge is what is important.
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum