Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: how to store value Post Reply Post New Topic
Author Message
mcotten
Newbie
Newbie


Joined: 04 Mar 2010
Online Status: Offline
Posts: 5
Quote mcotten Replybullet Topic: how to store value
     Posted: 04 Mar 2010 at 6:32pm
I am new to crystal reports and am trying to do a report for work. I have a field that needs to display a total of a specific field. I am having trouble with how to write the if statement in the proper syntax. In C++ I would define a variable called instotal and if a certain condition exists add the billing.charge to the instotal and once done display the instotal. It doesn't look like I can decalre a variable in the formula nor can I display a field that isn't in a table. Is this correct? If so how do I get around it?
IP IP Logged
razzak
Newbie
Newbie
Avatar

Joined: 03 Mar 2010
Location: India
Online Status: Offline
Posts: 34
Quote razzak Replybullet Posted: 05 Mar 2010 at 1:37am

you can create formula field in crystal report for your total purpose.

in field explore right click on formula --> new--->give name to formula field
then
 
Dim instot
instot = 1
if ({Command.bill} = 10) then formula =a+1
 
take this formula field in report.
 


Edited by razzak - 05 Mar 2010 at 1:38am
Razzak Sayyed
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 05 Mar 2010 at 7:08am
FYI: the example above is in BASIC format, CR format is slightly different.
IP IP Logged
mcotten
Newbie
Newbie


Joined: 04 Mar 2010
Online Status: Offline
Posts: 5
Quote mcotten Replybullet Posted: 05 Mar 2010 at 8:23am
I understand how to do the if statement but I don't know how to declare the variable and print that variable instead of an actual database field. In C++ I would of done something similiar to this, how does this work in CR?
 
double instotal=0.00;
 
if (transaction.type =2){
instotal = instotal + billing.payment;
}
endif;
print instotal;
 
IP IP Logged
kevlray
Admin Group
Admin Group
Avatar

Joined: 29 Oct 2009
Online Status: Offline
Posts: 1587
Quote kevlray Replybullet Posted: 08 Mar 2010 at 10:37am
In Crystal Format, this is what I would do
 
numbervar instotal := 0.00;  //No double declarations in CR
 
if ({tranaction.type} =2 then instotal := instotal + {billing.payment};
instotal;
 
 
Hope this helps.
 
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