Rounding numbers

  • Thread starter Thread starter Ivor Williams
  • Start date Start date
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
 
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
 
Another method that will work for POSITIVE values

-Int(-N * 50)/ N

RoundUp50: -Int(-5*50)/5
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top