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

Need help with Val() Function

Status
Not open for further replies.

kab097

Programmer
Jan 2, 2002
13
US
Version of CR 8.5

Per Ken's suggestion (thank you so much!!!) I am trying to convert a varchar field (CR says its a string field, and the values in these fields are purely numeric). However, I can't seem to get the val function to work for me.

Here is what I am doing (found this in the CR help section) in the formula editor:

val("{databasename.fieldname}")

It says the syntax is fine, but it converts all the string numbers to 0.00. Also, it does not show up as an Available Field when I go to try to use it in the chart expert.

I know I am doing somethign wrong, but I am not sure what I am missing. Thank you so much!!!
 
dump the "" around the fieldname Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 


I took the quotes out and I am still getting the same result.

val({database.fieldname})

It still comes up as all 0.00

Any other suggestions?
Thanks for you help!
 
if the {database.fieldname} is always numbers in a string format then just use

tonumber({database.fieldname})

Val is used when extracting the number portion of a string

eg. Val("123oak") returns 123

unless you have this situation use tonumber()
 
I apologize, I did not read your post closely.

The Val() function reads an alphanumeric string and stops when it encounters the first non-numeric, non-space charcter and returns a value.

ex: Val("1600 34th Street") returns 160034.

I do not know what happens if it NEVER encounters a non-numeric, non-space value, but it evidently doesn't work.

Try using the tonumber() function. Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Ok, this is what I have

tonumber({database.fieldname})

and it STILL is giving me 0.00

Am I supposed to be doing something else in the the formula editor? Am I supposed to be declaring something?

Again, thank you for all your help! Hopefully I will get this soon!
 
Typically no you would not need to declare a variable or anything else for tis simple of a formula.

Perhaps you can email me your report (with saved data)?

dgilsdorf@altavsita.com Software Support for Sage Mas90, Macola, Crystal Reports, Goldmine and MS Office
 
Thank you for the offer. I solved the problem at the source...I changed the varchar fields to numeric and it appears to be doing what I need it to do right now. Thanks so much everyone for your help!!

Have a great day!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top