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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

converting text to number, in Crystal Report

Status
Not open for further replies.

mishand

MIS
Jun 7, 2002
3
CA
How do I convert a field text to number when doing a report with Crystal Report ?

I want to do a total afterward with the number
 
ToNumber({textfield}) it how you do it. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
I tried to use ToNumber ({textfield}) and it doesn't work.

Is there another option ?

Thanks
 
When you say it "doesn't work" what happens? Do you get an error message? If so what is the message? Are you not getting an error but getting unexpected results? If so what are the unexpected results? Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
The tonumber function should will work in a formula even if you have a text string with commas and currency indications.

Please post an example of the text field you are trying to convert.

Mike

 
I want to do a Total or sub-total in a report. The field is in text but it's written 2.0 in it.

Can I do totals on text field ?

Thanks
 
Convert the "2.0" to a number with the ToNumber() function as suggested originally, then subtotal the formula field rather than the database field. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
I prefer to use VAL() instead of ToNumber(). If ToNumber hits an alpha character in any record it errors. Val() just returns a zero and keeps working. When you write the formula with Val() make sure you total on the new formula, not the original field. Ken Hamady, On-site Custom Crystal Reports Training & Consulting
Public classes and individual training.
Guide to using Crystal in VB
tek@kenhamady.com
 
Actually Val() works a little bit differently. If you Val("1234 Main Street"), the result will be the number 1,234. In short it will return the numeric value of the first X number of characters it finds, ending with first alpha character it finds. If the string starts with an alpha character it returns zero.

Having said that, Val() probably is better because at least it will never error on a string, where ToNumber() will. Software Support for Macola, Crystal Reports and Goldmine
dgilsdorf@mchsi.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top