Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ToNumber Help

Status
Not open for further replies.

szeiss

Programmer
Apr 5, 2000
137
US
I have a report that is accessing data from an Oracle 8i database.&nbsp;&nbsp;The field in the table I'm accessing is called FiscalYear and is stored as a VARCHAR2(4) with data such as 1998, 1999, 2000.&nbsp;&nbsp;If I click on the field in CR8 and browse the field, it says it's a string value.&nbsp;&nbsp;I also have a parameter field in my report called StartYear which is a number.&nbsp;&nbsp;My formula is:<br><br>ToNumber({BUDGET_HISTORY_AFS2.FISCALYEAR})={?StartYear}-1<br><br>I then get the error message &quot;string is non-numeric&quot; which according to help means &quot;The string is non-numeric.<br>The argument to the ToNumber function must be a number stored as a string (for example, a customer number, an ID number, etc.). The string may be preceded by a minus sign and may contain leading and trailing blanks. You have used an argument that is non-numeric and therefore cannot be converted to a number. Change the argument to numeric and recheck.<br><br>I can't seem to figure this one out, can anyone help.<br><br>Thanks,<br>Sherry
 
Check out the Val function, and the following is good practice:<br>From Crystal Reports help...<br>When using the ToNumber function, you should first test the value with the NumericText function. NumericText returns a value of TRUE only if the value in the string can be correctly converted to a number. Otherwise, if you try to convert a value to a number that is not a number, the formula will produce an error in your report. The following example is a common use of the NumericText and ToNumber functions together:<br>If NumericText ({file.FIELD}) Then<br> ToNumber ({file.FIELD})<br>Else<br> 0<br><br><br> <p>Malcolm Wynden<br><a href=mailto:wynden@island.dot.net>wynden@island.dot.net</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top