Results 1 to 5 of 5
  1. #1
    jasonmv22 is offline Novice
    Windows 10 Access 2016
    Join Date
    May 2020
    Posts
    1

    Question Formula Rounding Problem

    *Please note - I am not the creator or manager of this access database, just an end user with no real knowledge of access whatsoever. Someone created this database for several sections of our company to input data into and produce reports, however there is one major issue with it that the creator can't seem to figure out. I just want to ask the experts here if a solution actually exists within access or if we will have to figure something else out.*



    We're having an issue with formulas and how the products are rounded within access. I work in aviation, where flight duration is an important stat. We report flight duration to 1 decimal place. It is not a stat we manually input; we input the take-off and land time and the system calculates duration (ex. a take-off of 0900 and land of 1030 results in 1.5 hour duration).

    The problem we are having is how the system rounds when the second decimal place is a 5. To follow in line with how we have always calculated flight duration, we need the system to round UP when the minute duration is under 30 and DOWN when minute duration is over 30.

    For example, if a flight is 1 hour 27 minutes (1.45 hours) we need access to round UP to 1.5 duration. If a flight is 1 hour 33 minutes (1.55 hours) we need access to round DOWN to 1.5.

    Does access have the ability to customize how it rounds in the way we need it to, or do you have to choose only either rounding up or rounding down?

    Thank you!!

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2016
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I suspect you may be running into "bankers rounding", described near the bottom here with a potential solution:

    http://allenbrowne.com/round.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,411
    We need the system to round UP when the minute duration is under 30 and DOWN when minute duration is over 30.
    to be clear - if flight time is 1:55 - you want that to round down to 1:30 (1.5) or flight time is 1:05 - that is to be rounded up to 1:30 (1.5)?

    And you are not using 6 minute intervals? so you don't want 1.1, 1.2 etc

    at the end of the day, it's only maths

  5. #5
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,898
    My approach to deal with rounding issue:
    Code:
    Function RRound(FieldValue As Variant, Optional intPos As Integer = 0) As Variant
    '--------------------------------------------------
    ' Function RRound() rounds value to designated decimal position.
    ' If argument does not contain data, RRound returns null.
    ' Use because intrinsic Round uses even/odd (banker's) rounding.
    ' Also, Format and FormatNumber functions don't use even/odd but
    ' generate a string result which is often inconvenient.
    '--------------------------------------------------
    Dim strZeros As String
    Dim i As Integer
    If intPos = 0 Then
        strZeros = 0
    Else
        For i = 1 To intPos
            strZeros = strZeros & 0
        Next
        strZeros = "0." & strZeros
    End If
    RRound = IIf(Not IsNull(FieldValue), Val(Format(FieldValue, strZeros)), Null)
    End Function
    

    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

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

Similar Threads

  1. Problem with rounding code
    By lccrews in forum Queries
    Replies: 2
    Last Post: 08-28-2017, 10:50 AM
  2. Replies: 12
    Last Post: 10-22-2012, 06:11 AM
  3. Rounding Problem With Percentages
    By Lady_Jane in forum Queries
    Replies: 5
    Last Post: 09-01-2011, 02:32 PM
  4. Rounding problem
    By chavez_sea in forum Access
    Replies: 6
    Last Post: 03-09-2011, 09:01 PM
  5. Rounding problem
    By jgelpi16 in forum Queries
    Replies: 1
    Last Post: 04-06-2010, 10:27 AM

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