• Rounding (Access 97)

    Author
    Topic
    #362002

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

    Viewing 2 reply threads
    Author
    Replies
    • #548811

      You could use

      expression:=Round(Avg([Turnarounddays],NumberOfDecimalsToRoundTo)

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

      • #548906

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

        • #548909

          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

          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

    • #548813

      Round it to what?

    • #548908

      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.

      • #548910

        Ooops, sorry, must have been in the middle of hacking together the function. blush

        • #548921

          No problem. It’s just that I’m from California and doing my bit for the energy crisis by conserving my own energy. grin Searching the lounge will often turn up a preexisting solution and save me from having to create something new. evilgrin

    Viewing 2 reply threads
    Reply To: Rounding (Access 97)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: