Results 1 to 6 of 6
  1. #1
    smg is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Apr 2019
    Posts
    121

    Rounding help needed

    I have the following formula:



    Premium: IIf([Q2A]![E/NE]='N',([Q2A]![ByWkAccrual]/[Q2A]![SumOfCharged Hours])*0.5*[Q2A]![OT Hours],0)

    I now need to add rounding to two decimal placess to this but I can't seem to make it work. Help. How should this formula read to accomplish rounding?

    Thanks

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    You didn't say where to round (table, form control, expression...) nor did you say if the field (assuming there is one) is a number or text data type.

    If table and numeric field, simply set the property sheet format value to fixed and the decimal places to 2. A report and form controls should show the rounded value.
    If this has anything to do with $ you might want to investigate how Access rounds. IIRC there could be issues for you.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    smg is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Apr 2019
    Posts
    121
    query on numeric field(s)

  4. #4
    ssanfu is offline Master of Nothing
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    I agree with Micron. If you do not understand the rounding methods, your numbers could be off (could be issues). There are Banker's Rounding, Rounding Up, Rounding Down, Round To The Nearest, ....

    Remember that Rounding (unless you are storing the rounded number in a table) only affects the display of the number.




    So, in a query, you could try
    Code:
    Premium: IIf([Q2A]![E/NE]='N',([Q2A]![ByWkAccrual]/[Q2A]![SumOfCharged Hours])*0.5*[Q2A]![OT Hours],0)              ' <<--  original
    
    
    Premium: IIf([Q2A]![E/NE]='N',Round((([Q2A]![ByWkAccrual]/[Q2A]![SumOfCharged Hours])*0.5*[Q2A]![OT Hours]),2),0)   ' <<--  with rounding

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,818
    Unless the source numbers (from tables) are long or integer type, decimal or single data type Access should be rounding up in your query or table. It does for me if I set Fixed and 2 decimal places in the query property sheet. Or perhaps try
    Code:
    Round(IIf([Q2A]![E/NE]='N',([Q2A]![ByWkAccrual]/[Q2A]![SumOfCharged Hours])*0.5*[Q2A]![OT Hours],0),2)
    If that doesn't work consider posting a zipped copy of the db.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  6. #6
    smg is offline Competent Performer
    Windows XP Access 2010 64bit
    Join Date
    Apr 2019
    Posts
    121
    Thank you all. I will try fixed, 2 decimal places and read up on MS Access rounding.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-07-2018, 08:05 AM
  2. Rounding up
    By UT227 in forum Queries
    Replies: 5
    Last Post: 07-18-2017, 10:35 AM
  3. Why Is It Rounding?
    By bgwool in forum Access
    Replies: 4
    Last Post: 12-10-2014, 06:24 PM
  4. Help needed : Library catalogue in access format is needed
    By dealers in forum Sample Databases
    Replies: 3
    Last Post: 01-16-2014, 02:03 PM
  5. Rounding off
    By Alex Motilal in forum Access
    Replies: 4
    Last Post: 12-20-2009, 12:47 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums