Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Help Post Reply Post New Topic
Author Message
achartrand
Newbie
Newbie
Avatar

Joined: 27 Apr 2010
Location: Canada
Online Status: Offline
Posts: 8
Quote achartrand Replybullet Topic: Help
    Posted: 07 May 2010 at 6:55am

I created a field called counter, which get increased by 1 everything a record is retrieved and it will restart back to one every time it reaches 3.

 

Formula Field: counter

numberVar c = 0;

Whileprintingrecords;

c := c + 1;

if  c > 3 then

 c := 1;

 

I have another field that I want to concatenate the results together

StringVar data;

Whileprintingrecords;

    data & {@fieldName}

 

 

The last field I have, I want to have the

{@counter}

But for some reason when I run the report I get the result of

0

0

0

1

D

 

Not

1 2 3 1

My problems are that my counter isn’t working correctly and the data isn’t being concatenated together, it seems like there is a line break after the data.

Any help? Thanks

IP IP Logged
FrnhtGLI
Senior Member
Senior Member
Avatar

Joined: 22 May 2009
Online Status: Offline
Posts: 347
Quote FrnhtGLI Replybullet Posted: 07 May 2010 at 9:36am
You need to take out the numberVar C = 0; out of the formula. That will set the formula to 0 every time it is evaluated. If you ever need to set it back to zero then put either another field that is just the numberVar C = 0; portion or have another evaluation in the @Counter formula or when it gets to a certain number (as it does for the 1).
 
I'm assuming that your @Counter field is in either a detail section or report header or footer and that is why you are getting the field on top of each other. If you are wanting them side-by-side I would suggest also declairing a string variable that will store the fields in it and then just suppress it until you want to display it.  So something like this:
 
whileprintingrecords;
 
global numberVar nC:=(if nC<3 then nC+1 else 1);
global stringVar sC:=sC & " " & totext(nC,0);
|< /\ '][' ( )
IP IP Logged
Post Reply Post New Topic
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



This page was generated in 0.031 seconds.