When it comes to talking about Microsoft Access, it seems that two tiny versions of me *poof* into existence, each sitting on a shoulder. The guy on my right wears a suit and always reminds me how great of a tool Access is because it empowers small organizations to develop productivity and information systems. The other guy, sporting a “l337 h4x0r“ tee and cut-off jeans, screams in my ear that “Access is a complete abomination“ and that the tools to create applications should not be put in the hands of laymen.

For some odd reason, as I'm about to post this currency-rounding Access function (discovered by Jeff Smith), the business-savvy mini-me didn't even bother showing up ...

Function roundoff(x)
    Dim frac As String, Result As String
    Dim LenFrac As Integer
    
    frac = x - Fix(x)
    frac = frac * 1000
    frac = Fix(frac)
    If Left(frac, 1) = "-" Then
        LenFrac = Right(frac, Len(frac) - 1)
        If Len(LenFrac) = 2 Then
            frac = "-0" & LenFrac
        ElseIf Len(LenFrac) = 1 Then
            frac = "-00" & LenFrac
        End If
    Else
        If Len(frac) = 2 Then
            frac = "0" & frac
        ElseIf Len(frac) = 1 Then
            frac = "00" & frac
        End If
    End If
    If x > 0 Then
        If Right(frac, 1) > 4 Then
            frac = Left(frac, 2) + 1
        Else
            frac = Left(frac, 2)
        End If
    Else
        If Right(frac, 1) > 4 Then
                frac = Left(frac, 3) - 1
        Else
            frac = Left(frac, 3)
        End If
    End If
    frac = Format(frac / 100, "@@")
    Result = Fix(x) + frac
    roundoff = Result
End Function