Rounding numbers

I

Ivor Williams

I've created a query which returns whole numbers. I would like to round
these numbers up to the nearest 50 so 15 is rounded to 50, 60 is rounded to
100, etc. How can this be done?

Thanks,
Ivor
 
K

Ken Snell [MVP]

This expression should work for whole numbers to be rounded up to nearest 50
(MyNumber should be replaced by whatever holds the original value):

(((MyNumber) + 49) \ 50) * 50


You could put this into a function and then call the function:

Public Function RoundUpTo50(varValue)
RoundUpTo50 = (((varValue) + 49) \ 50) * 50
End Function
 
J

John Spencer (MVP)

Another method that will work for POSITIVE values

-Int(-N * 50)/ N

RoundUp50: -Int(-5*50)/5
 
K

Ken Snell [MVP]

Slick!

--

Ken Snell
<MS ACCESS MVP>

John Spencer (MVP) said:
Another method that will work for POSITIVE values

-Int(-N * 50)/ N

RoundUp50: -Int(-5*50)/5
 
Top