J
Jamie Collins
The Val() function will convert a text string which can be interpreted as a
number to a number
Specifically, a FLOAT (Double) value e.g.
SELECT TYPENAME(VAL(0))
returns 'Double'.
You'll need to decide on the datatype of the number field first: do these
numbers havedecimalplaces? If so you can't use the default Long Integer
number type. Do they exceed two billion? Likewise. Do you need fifteen or more
digits of precision?
....so if the OP decides that they *do* need more than fifteen digits
of precision, using the VAL() expression could result is a loss of
precision e.g.
SELECT 76543210987654329 - 76543210987654320 AS
decimal_result_correct,
VAL(76543210987654329) - VAL(76543210987654320) as
float_result_incorrect
So DECIMAL would be my preference (up to 28 digits of precision,
supports decimal values, rounds by truncation not banker's, etc).
Sadly, the CDEC() expression remains broken in Jet, but an implicit
cast to DECIMAL may be possible, noting that Jet uses the DECIMAL type
natively for values within certain ranges e.g. this works:
SELECT '76543210987654329' + 0.1 - 0.1 AS decimal_value,
TYPENAME('76543210987654329' + 0.1 - 0.1) AS decimal_type_name
returns 'Decimal'.
Jamie.
--