Update Query error (access 97)

  • Thread starter Thread starter T.K. Lim
  • Start date Start date
T

T.K. Lim

I'm using these statement to update my table and found
wrong result.

UPDATE syinvdtl SET qty = qty - 500
WHERE syinvdtl.pcode = "GR1" and syinvdtl.uom = "PACK";

For table syinvdtl, i declare field qty as Number(Single)
with AUTO decimal places.

My qty initially has value 483.30, the result should be
483.3 - 500 = -16.70 but it appears as -16.70001. I try
few times but it seems to come out with same result.

May i know is this application bug or anything wrong with
my code
 
That's standard for doing decimal arithmetic on computers. Just as we can't
represent certain fractions exactly in base 10, computers can't represent
them all in base 2, so you experience round-off errors.

You can try using a Currency field rather than a single or double.

Check out the following articles for more details:

http://support.microsoft.com/default.aspx?kbid=42980
http://support.microsoft.com/default.aspx?kbid=279755

(Ignore the list of products mentioned in the 2 articles: it applies to all
applications, not just the limited list cited)
 
Back
Top