Technical Questions
 Crystal Reports Forum : Crystal Reports 9, X, XI, 2008, 2011 : Technical Questions
Message Icon Topic: IF Then Else IF Post Reply Post New Topic
Author Message
wsparks
Newbie
Newbie


Joined: 26 Jun 2008
Location: United States
Online Status: Offline
Posts: 5
Quote wsparks Replybullet Topic: IF Then Else IF
    Posted: 26 Jun 2008 at 8:31am
Hi,
I'm somewhat new to Crystal Report Writing and I am trying to run an "If then else if" formula to return a different rate depending on the certain value. 
 
Basically I am linking two tables together in the Database expert by a paycodeid and if the paycodeid belongs to a certain GrandPaycodeid specify a different hourly rate. 
 
This is what I have so far, but I am getting a "String is required here" on the second occurance of "If".
 
If {PAYCAT1MM.GRANDPAYCODEID} = 11001 then {KNX_VIEW_WFCTTL_LABOR.LABORLEV5DSC}
Else IF {PAYCAT1MM.GRANDPAYCODEID} = 11002 then 1.1 * {@Base Rate}
Else IF {PAYCAT1MM.GRANDPAYCODEID} = 11003 then {@Base Rate}
 
A paycodeid is assigned to only one of the above GrandPaycodeID's.
IP IP Logged
saoco77
Senior Member
Senior Member


Joined: 26 Jun 2007
Online Status: Offline
Posts: 104
Quote saoco77 Replybullet Posted: 26 Jun 2008 at 9:29am
It looks like your first if statement is returning a string while your second and third if statements are returning a numeric value.

In crystal a formula can't return two different data types. Try:

totext(1.1 * {@Base Rate})

Hope this helps.

Sarah


IP IP Logged
wsparks
Newbie
Newbie


Joined: 26 Jun 2008
Location: United States
Online Status: Offline
Posts: 5
Quote wsparks Replybullet Posted: 26 Jun 2008 at 10:57am
Thanks, that works, although I reversed it and put a tonumber on the first line.  Now I just need to figure out why once I add the formula to my report it no longer returns data.
IP IP Logged
wsparks
Newbie
Newbie


Joined: 26 Jun 2008
Location: United States
Online Status: Offline
Posts: 5
Quote wsparks Replybullet Posted: 26 Jun 2008 at 11:19am
I figured out why its not returning any data, I just need to figure out a solution.
 
While my Paycodeid only exists in one of the three grandpaycodes when I started this report and grandpaycode of ALL was made, so I added the new GrandPaycode to the formula to see if it would return a rate and it did. 
 
Can I make the If Then Statement LOOP until it finds one of GrandPaycodeID's that I need?
 
Maybe add the following line and if true to return to the top of the IF Then statement???
Else IF {PAYCAT1MM.GRANDPAYCODEID} = 11051
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.047 seconds.