Data Type Change

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a text field that contains "1.25" and want it to be a number field.
It errors on Data Type mismatch when I try to put it in a numeric field. Is
there any way to get text to be numeric so arithmetic can be done? Thanks
for the help!
 
vtj wrote in message
I have a text field that contains "1.25" and want it to be a number field.
It errors on Data Type mismatch when I try to put it in a numeric field. Is
there any way to get text to be numeric so arithmetic can be done? Thanks
for the help!

I don't know exactly what you ask, but look up the functions Csng,
Cdbl,
CCur, CDec according to the datatype you're converting too under the
help topic Type Conversion Functions. Then there's also the Val
function. See if any of this helps, or post back with a bit more info
on how/what you're doing.
 
The Val function works!! thanks!!

RoyVidar said:
vtj wrote in message


I don't know exactly what you ask, but look up the functions Csng,
Cdbl,
CCur, CDec according to the datatype you're converting too under the
help topic Type Conversion Functions. Then there's also the Val
function. See if any of this helps, or post back with a bit more info
on how/what you're doing.
 
Val works as long as you don't have a null value.

Also it returns Zero for strings that can't be interpreted as numbers. If
you have "99Times" it will return 99.

I prefer something a little more complex to ensure I am only converting
fields that are all numbers.

IIF(IsNumeric([SomeField]),Val([SomeField]),Null)

Even that can have some problems as IsNumeric will see "111e2" as a number
expressed with scientific notation.
 
John Spencer wrote in message said:
Even that can have some problems as IsNumeric will see "111e2" as a number
expressed with scientific notation.

Don't forget the same also goes for "111D2" ;-)
 
Another potential gotcha is currency symbols. On my system ...

? isnumeric("¤1")
True
? isnumeric("$1")
False

The symbol in the first example is the Euro symbol. If you run that code on
a PC configured with typical US settings, you'll get the opposite result.
 
Back
Top