why are my decimals truncated?

H

Howards

I have a basic access table and form. I have several fields that use a
number, with decimals in it. However, everytime I insert data, either in the
table or the form, it always truncates my decimal values (and does not round
up.)

I have redone the table and form without any improvement.

I have used the auto decimal format. I have tried the fixed format with 2
decimal values, and it even will convert a 43.4 to 43.00. I am not sure how
to fix this. Any ideas?
 
K

KARL DEWEY

What precission of number do you have? Integer, single, double?

You do know that an integer can only have whole numbers.
 
J

John W. Vinson

I have a basic access table and form. I have several fields that use a
number, with decimals in it. However, everytime I insert data, either in the
table or the form, it always truncates my decimal values (and does not round
up.)

I have redone the table and form without any improvement.

I have used the auto decimal format. I have tried the fixed format with 2
decimal values, and it even will convert a 43.4 to 43.00. I am not sure how
to fix this. Any ideas?

The Format is *irrelevant* to the problem.

The default size for Number is Long Integer. An integer is, by definition, a
whole number.

Open the table in design view, select this field, and look at the field
properties in the lower left corner. The first row will probably say Long
Integer. You can change this to Single or Double.

Better, if you need just two decimal places (say you're storing money values,
although it works for non-money data just as well) is to not use a Number
datatype at all but rather a Currency datatype. This gives you four decimal
places and no roundoff error, which can be a problem with Single or Double.

John W. Vinson [MVP]
 
J

Jamie Collins

Single or Double.

Better, if you need just two decimal places (say you're storing money values,
although it works for non-money data just as well) is to not use a Number
datatype at all but rather a Currency datatype. This gives you four decimal
places and no round off error

I think you must mean "no round off error at just two decimal places"
because at more than four decimal places CURRENCY will exhibit
banker's rounding, which could be an error if the designer intended
another rounding algorithm.

Better IMO to use the DECIMAL data type, whose inherently rounding
algorithm is that of symmetric truncation (a.k.a. no rounding at
all!); the general approach is to increase the decimal scale by one
(something you can't do with CURRENCY) i.e. an additional decimal
place so the front end application can have do its own explicit
rounding.

Jamie.

--
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top