Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula for changing the displayed data Post Reply Post New Topic
Author Message
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Topic: Formula for changing the displayed data
     Posted: 23 Apr 2010 at 10:48am
Crystal Report XI: I'm pulling data from MS Access 2007 using radio buttons which show the value in Access as 1 or 2. I'm looking for a formula to convert the 1 to 'IFS' and the 2 to 'Related' once it's on the CR.
Thanks.
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 23 Apr 2010 at 10:49am
If {table.field} = 1 then 'IFS' else 'Related'
 
-Dell
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 23 Apr 2010 at 10:55am
Thanks for the fast response. With this formula:
 
If {tblWilliamsGrantExpenditures.Expenditures} = 1 then 'IFS' else 'Related'
 
 I get an error message highlighting the '1' saying a string is needed here. One thing I forgot to mention in my original post is what happens if there's a NULL value? Which may be the reason for the error?
 
After working with it for a few minutes, I notice that if it's a NULL value, it shows up in CR as 'YES' instead of a 1 or 2.........


Edited by jgarner - 23 Apr 2010 at 11:04am
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 26 Apr 2010 at 3:35am
Originally posted by jgarner

If {tblWilliamsGrantExpenditures.Expenditures} = 1 then 'IFS' else 'Related'
 
 I get an error message highlighting the '1' saying a string is needed here.
 
Any idea why I'm getting this error message?
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 26 Apr 2010 at 3:36am
How do you want to handle the null?  You need to check for it first because of the way that databases handle null.  Null is not actually a value, so when you do a comparison of a null value to a real value, the return value is null instead of true or false.
 
So, your formula will look something like this:
 
If IsNull({tblWilliamsGrantExpenditures.Expenditures}) then
  ''
else if {tblWilliamsGrantExpenditures.Expenditures} = '1' then 'IFS'
else 'Related'
 
-Dell
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 26 Apr 2010 at 3:37am
You're getting the error message because the field that contains the 1 is a string field, not a numeric field.  Put the 1 in quotes to solve the problem.
 
-Dell
IP IP Logged
jgarner
Senior Member
Senior Member


Joined: 23 Jan 2009
Location: United States
Online Status: Offline
Posts: 159
Quote jgarner Replybullet Posted: 26 Apr 2010 at 3:40am
That did the trick. I just used the word 'None' to populate the NULL values. Thanks hilfy!
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