Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: how to reset veriable? Post Reply Post New Topic
Author Message
manho88
Newbie
Newbie


Joined: 09 Mar 2010
Location: Hong Kong
Online Status: Offline
Posts: 6
Quote manho88 Replybullet Topic: how to reset veriable?
     Posted: 09 Mar 2010 at 9:58pm
I create a formula to calculate the total for the following field, which is group by InvNo.
 
whilereadingrecords;
 
numbervar total_fee := total_fee + {statementRe.RoadFee} + {statementRe.WeighFee} +{statementRe.CheckFee}+{statementRe.QuarantineFee}+{statementRe.ParkFee}+{statementRe.RegisterFee}+{statementRe.TunnelFee}+{statementRe.CustomsFee}+{statementRe.OtherFee};

total_fee

This formula is working fine to calculate the fee, but I want it reset when the {statementRe.InvNo} is change.
 
I try to create another formula to reset, I got this error message
"This function cannot be used because it must be evaluated later."
 
WhilereadingRecords;
 
if {statementRe.InvNo} <> Previous({statementRe.InvNo}) then
   numbervar  total_fee :=0;
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 10 Mar 2010 at 6:06am
WhilereadingRecords;
 numbervar  total_fee;  
if {statementRe.InvNo} <> Previous({statementRe.InvNo}) then
   total_fee :=0;
IP IP Logged
manho88
Newbie
Newbie


Joined: 09 Mar 2010
Location: Hong Kong
Online Status: Offline
Posts: 6
Quote manho88 Replybullet Posted: 10 Mar 2010 at 4:15pm
hi lockwelle,
 
thank for yours help, I add the line but still get the error message
 
"This function cannot be used because it must be evaluated later."
 
But if i change this
 
whilereadingrecords; 
 
to
 
whileprintingrecords;
 
no error message appear, but the total_fee not reset
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Mar 2010 at 11:25am

where are you using the formula?  I have rarely gotten a must be evaluted later type error, so I would be curious to know.

IP IP Logged
manho88
Newbie
Newbie


Joined: 09 Mar 2010
Location: Hong Kong
Online Status: Offline
Posts: 6
Quote manho88 Replybullet Posted: 11 Mar 2010 at 9:00pm

I got the message when I completed writing the formula and press the Save button, the formula were not place in the report

IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 12 Mar 2010 at 6:12am
Off-hand, I don't know why it would give an error like that.  You could try creating another variable to store the InvNo...I am wondering if Previous is having an issue...it shouldn't, but everything else is pretty standard.
 
HTH
IP IP Logged
manho88
Newbie
Newbie


Joined: 09 Mar 2010
Location: Hong Kong
Online Status: Offline
Posts: 6
Quote manho88 Replybullet Posted: 13 Mar 2010 at 12:42am
actually the code working well if i don't create the group InvNo.

Now, I solved the problem by adding RT total first and then create a formula to add all RT total.

thank

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