Data Connectivity
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Data Connectivity
Message Icon Topic: Tonumber not working Post Reply Post New Topic
Author Message
lyman
Newbie
Newbie
Avatar

Joined: 01 May 2009
Online Status: Offline
Posts: 12
Quote lyman Replybullet Topic: Tonumber not working
    Posted: 20 Feb 2013 at 8:03am
I'm trying to sort blood pressure readings (120/90)  in order so I parse out the first number and sort them. My formula(s) are  
If NumericText({text_1}) then
TONumber(Left({text_1},InStr(1,1},"/")-1)) else
0
 
The error message is "String length is less than 0 or not an integer"
 
If InStr({text_1},"/")>1 then
ToNumber(Left({text_1},InStr(1,{text_1},"/")-1)) else
0
 
Error message: The string is non-numeric.
 
What am I doing wrong here. 
 
 
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 20 Feb 2013 at 11:12am
Is there any chance that {text_1} is null?  If so, you need to do one or more of the following things:
 
1.  In the Formula Editor, look for "Exceptions for nulls" in the button bars at the top of the screen.  Change it to "Default values for nulls".
 
2.  Go to the File menu and select Report Options and turn on "Convert NULL values to default".
 
3.  Handle it the old-fashioned way by checking for null in your formula - something like this:
 
If IsNull({text_1}) or not NumericText({text_1}) then 0
else ToNumber(Left({text_1},InStr(1,1},"/")-1))
 
NOTE:  If using method 3 you ALWAYS have to test for NULL first!
 
-Dell
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.000 seconds.