424,949 Members | 1,086 Online
Need help? Post your question and get tips & solutions from a community of 424,949 IT Pros & Developers. It's quick & easy.

# Query - incorrect output when usingthe INT function

 P: 19 Hi, I have a field in a query, as follows - SharesToPurchase: [TotalCash] / [Forms]![frm_EnterPurchaseDetails]![txtEnterPurchasePrice] where [TotalCash = 272.58, and [txtEnterPurchasePrice] = 6.49. Dividing [TotalCash] by [txtEnterPurchasePrice] should come to exactly 42. This is the only case in my data set where the result works out to a whole number - the rest have fractions. They should all be whole numbers. The problem I'm having is, when I apply the INT function to the above formula, the result of the formula using the figures above is now 41, not 42?! The rest are fine. Please help! Oct 19 '06 #1

Access 2K has a Round() function.
More to the point, non-integer arithmetic will nearly always result in a value which is very close, but not equal to, the correct integral value.

Hence, in this case, because the answer is actually an exact integer, the possibility is open for a rounding error.

If you use the Round() function instead, you will still have exactly the same arithmetic, but the problem should not manifest itself due to the nature of rounding as opposed to truncating.

4 Replies

 100+ P: 143 Try Round instead of Int Oct 19 '06 #2

 P: 19 Sorry, I forgot to mention that this is Access 2000, and there is no round function. All I need to do is remove the fractional part, but not round it. Thanks. Oct 19 '06 #3

 Expert Mod 15k+ P: 31,342 Access 2K has a Round() function. More to the point, non-integer arithmetic will nearly always result in a value which is very close, but not equal to, the correct integral value. Hence, in this case, because the answer is actually an exact integer, the possibility is open for a rounding error. If you use the Round() function instead, you will still have exactly the same arithmetic, but the problem should not manifest itself due to the nature of rounding as opposed to truncating. Oct 19 '06 #4

 P: 19 Thanks. That worked. I didn't realise there was a Round function as it wasn't listed in the functions list within the Expression Builder. Oct 19 '06 #5