Rounding to nearest .25

Jeff H
4StarLounger
Posts: 415
Joined: 31 Oct 2017, 20:07

Rounding to nearest .25

Post by Jeff H »

In Excel I use =MROUND(A1,0.25) to round a 2-digit decimal to the nearest 0.25. Is there an equivalent in Access?

I've tried to look it up online, but the answers I found were pretty convoluted. I'm hoping there's an easier way.

TIA,
- Jeff

User avatar
HansV
Administrator
Posts: 78391
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Rounding to nearest .25

Post by HansV »

You can use Round(Expression/0.25,0)*0.25 where Expression is the value you want to round.

More in general, you could create the following function in a module in the Visual Basic Editor:

Code: Select all

Function MRound(number As Double, multiple As Double) As Double
    MRound = Round(number / multiple, 0) * multiple
End Function
This can be used just like the Excel function, for example in a query:

RoundedAmount: MRound([Amount],0.25)

or in the Control Source of a text box on a form or report:

=MRound([Amount],0.25)
Best wishes,
Hans

Jeff H
4StarLounger
Posts: 415
Joined: 31 Oct 2017, 20:07

Re: Rounding to nearest .25

Post by Jeff H »

Very nice! Thanks a lot. I hope the next people asking this question on Google find your reply.

- Jeff