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

Number conversion problem 1

Status
Not open for further replies.

Cort

MIS
Apr 16, 2002
154
US
Hello all.

I have a text field that contains only numbers but the output is along the line sof "00025636" and "02236354", etc. There are always leading zeros.

I have to use this field as part of a larger forumla comparing it to an actual number field from another table. My formula looks something like this:

if isnull([number field]) or if [number field] = 0 then tonumber([text field]) else [number field]

Now this fails and I get "[text field]" is non-numeric errors. I can use totext to convert the number field to text but then I get those ugly zeros in the output.

Any way to force that text field into a number or make the output look like a number at least?

Thanks
 
Try:

if not(isnull({table.field})) then
val({table.field})
else
0

This will always return a number, providing that the field is null or has a number stored as a string.

-k
 
Thanks that worked great.

Learn something new every day.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top