Multiplying in Access

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ziccardi
    New Member
    • Mar 2010
    • 12

    Multiplying in Access

    I am trying to multiply 2 fields in Access
    Field1 has a value of 70.1
    Field2 has a value of 2.05

    Formula is
    [Field1] * [Field2]

    Result is 143.70499665737 2

    Help!! I really need it to give me the correct result of 143.705
    I don't have a clue why access is not multiplying this correctly.

    Just in case this makes a difference:
    Field1 is defined on the table as Currency-Currency-Auto (decimal places)
    Field2 is defined on the table as Number-Single-Fixed (6 decimal places)
  • ADezii
    Recognized Expert Expert
    • Apr 2006
    • 8834

    #2
    Try:
    Code:
    =FormatNumber([Field1] * [Field2],3)

    Comment

    • Stewart Ross
      Recognized Expert Moderator Specialist
      • Feb 2008
      • 2545

      #3
      All floating-point calculations are subject to rounding errors. Your second field is defined as of type single-precision - the lowest-accuracy form of floating-point storage used in VBA. Even if you used double-precision floating point values - which I would use as a matter of routine and not use the Single type at all - you will still face rounding errors in calculations.

      ADezii's suggestion of using formatting to round the number is a good one.

      I would use a double-precision field and simply round it for display purposes, using either formatting to three decimal places as ADezii suggests or explicit rounding (assuming that no further calculations are necessary):

      =Round([Field1]*[Field2), 3)

      By the way, using names such as Field1 and Field2 is a waste of a field name. Give your fields meaningful names that tell the reader what your field is storing.

      -Stewart

      Comment

      • TheSmileyCoder
        Recognized Expert Moderator Top Contributor
        • Dec 2009
        • 2322

        #4
        Thats Access 2007 for you. Makes it way to easy to create tables with meaningless field names. :)

        Comment

        • ziccardi
          New Member
          • Mar 2010
          • 12

          #5
          Actually I do have better field names but for the purpose of posting the question I tried to simplify. The answer given by ADezii seems to have fixed by problem. Thank you everyone for your help.

          Comment

          Working...