Rounding Problem

Llobid

Registered User.
Local time
Today, 15:48
Joined
Sep 20, 2004
Messages
26
I have tried to search and find a similar problem and solution, but have so far been unable. In an invoice form, I have a control that is the sum of several others (no problems), but then the control is multiplied by a tax rate and displayed in "Currency" format and 2 decimal places ... still no problem.

The problem comes when the customer submits payment in dollars and cents and that amount is subtracted from the charges. Here is an example:

The customer is charged $150.00 for a service and taxed at a rate of 6.25%. When $150.00 is multiplied by 0.0625, the result is 9.375. This is added to $150.00 to yield $159.375, which is rounded to $159.38 (correctly). However the customer submits a payment of $159.38 and the program subtracts the two and the result is displayed as ($0.01) ... $0.005 rounded up :eek:. I would prefer that the result be $0.00. Can someone explain how to fix this annoying problem?

Thanks for your help!
 
It isn't rounding what's stored, just what's displayed. When you make your calculation, use the Round() function (or a custom equivalent) so you only store 2 digits:

Round(amount * taxrate, 2)
 
Thanks Paul...but where exactly should I put that expression? I assume it would be in the properties dialogue box, but where? Also, I've read that people have had some problems with Access rounding even integers up and odd integers down with the "Round" function; is that likely here?
 
Wherever you're doing the calculation now. Just wrap your existing calculation in the Round() function. Access does what's called bankers rounding, which means it basically alternates rounding .5 up and down. Some people use custom rounding functions to change that.
 

Users who are viewing this thread

Back
Top Bottom