Query - incorrect output when usingthe INT function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • birchw
    New Member
    • Oct 2006
    • 19

    Query - incorrect output when usingthe INT function

    Hi, I have a field in a query, as follows -
    SharesToPurchas e: [TotalCash] / [Forms]![frm_EnterPurcha seDetails]![txtEnterPurchas ePrice]

    where [TotalCash = 272.58, and [txtEnterPurchas ePrice] = 6.49. Dividing [TotalCash] by [txtEnterPurchas ePrice] 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!
  • Tanis
    New Member
    • Mar 2006
    • 143

    #2
    Try Round instead of Int

    Comment

    • birchw
      New Member
      • Oct 2006
      • 19

      #3
      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.

      Comment

      • NeoPa
        Recognized Expert Moderator MVP
        • Oct 2006
        • 32636

        #4
        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.

        Comment

        • birchw
          New Member
          • Oct 2006
          • 19

          #5
          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.

          Comment

          Working...