Rounding numbers is not correct

J

Janis in Minnesota

I have some fields that I am totalling. They are all currency fields. In
the code I am running, the fields are 485 and 484.1666 (which should be
484.17) and 460.935 (which should be 460.94).
They view correctly (both on the form and report) when displayed as
currency, but the total only comes to 1430.10 when it should be 1430.11. I
am a penny off. What am I missing?
Thank you in advance for ANY help!
Thanks!

Janis in Minnesota
 
J

John W. Vinson/MVP

Janis in Minnesota said:
I have some fields that I am totalling. They are all currency fields.
In
the code I am running, the fields are 485 and 484.1666 (which should be
484.17) and 460.935 (which should be 460.94).
They view correctly (both on the form and report) when displayed as
currency, but the total only comes to 1430.10 when it should be 1430.11.
I
am a penny off. What am I missing?
Thank you in advance for ANY help!
Thanks!

Janis in Minnesota

This is a common mistake: you're confusing the storage of data with the
display of data. The Format of your field controls how the number is
displayed; you only see the two digits, but all four are still stored. When
you add them up, the hidden digits are still there and still add up, causing
the discrepancy.

It's best to use the Round() function to actually round the calculated
expressions to the penny, so what you see corresponds with what's actually
there.

John W. Vionson/MVP
 
Top