Results 1 to 8 of 8
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Posts
    1,119
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Rounding (Access 97)

    How do you round the following expression: =Avg([Turnarounddays])?

  2. #2
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rounding (Access 97)

    You could use

    <font color=6495ed>expression:=Round(Avg([Turnarounddays],NumberOfDecimalsToRoundTo)</font color=6495ed>

    Use this and replace NumberOfDecimalsToRoundTo with a number (default =0).

  3. #3
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Rounding (Access 97)

    Round it to what?
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  4. #4
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Rounding (Access 97)

    There's no built-in round function in Access 97. It came in with Access 2000.
    Charlotte

  5. #5
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Rounding (Access 97)

    Try doing a Lounge Search on rounding for previous threads on this question. Several of us have posted code before to handle rounding in Access 97.
    Charlotte

  6. #6
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rounding (Access 97)

    Oh damn, don't you hate that <img src=/S/smile.gif border=0 alt=smile width=15 height=15>

    Okay, here's a solution then. Paste the following function into a new module. You can then call the function CustomRound. It requires to variables to be passed to it, varValue, which is the value that you wish to be rounded and intDecimalPlaces, which is the number of decimal places that you want the number rounded to. The function returns null if there is a problem in evaluating the rounding.

    I haven't tested this in Access 97, but it should work...maybe you could let me know if it does.

    Cheers


    <font color=6495ed><font face="Georgia">Function CustomRound(varValue As Variant, intDecimalPlaces As Integer)
    '================================================= ====='
    ' Author: Jayden MacRae '
    ' Created: 27/10/2001 '
    ' Purpose: To round a value to the specified number of'
    ' decimal places. Function returns null if '
    ' it can't be evaluated. '
    '================================================= ====='
    If Not IsNumeric(varValue) Then
    CustomRound = Null
    Exit Function
    End If

    If intDecimalPlaces < 0 Then
    CustomRound = Null
    Exit Function
    End If

    CustomRound = CInt(varValue * 10 ^ intDecimalPlaces) / 10 ^ intDecimalPlaces
    End Function</font face=georgia></font color=6495ed>

  7. #7
    2 Star Lounger
    Join Date
    Apr 2001
    Location
    Wellington, New Zealand
    Posts
    173
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Rounding (Access 97)

    Ooops, sorry, must have been in the middle of hacking together the function. <img src=/S/blush.gif border=0 alt=blush width=15 height=15>

  8. #8
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Rounding (Access 97)

    No problem. It's just that I'm from California and doing my bit for the energy crisis by conserving my own energy. <img src=/S/grin.gif border=0 alt=grin width=15 height=15> Searching the lounge will often turn up a preexisting solution and save me from having to create something new. <img src=/S/evilgrin.gif border=0 alt=evilgrin width=15 height=15>
    Charlotte

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •