Rounding Up to Nearest Multiple of 10

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What Access function would I use to round an integer up to the nearest
multiple of 10 (e.g., 34 to 40, 87 to 90, etc.). In Excel one can use the
Ceiling function. Thanks in advance!
 
There isn't one. You'll have to roll your own or tap into the Excel library
and use that one.

BTW, this forum is really for Access SQL Queries.
 
Meangene,

I am not sure whether there is a more elegant way, but this works...

([YourNumber]\10-([YourNumber] MOD 10 <>0))*10
 
(e-mail address removed)...
What Access function would I use to round an integer up to the nearest
multiple of 10 (e.g., 34 to 40, 87 to 90, etc.). In Excel one can use the
Ceiling function. Thanks in advance!

40 isn't the nearest multiple of 10 to 34, 30 is. If you want to always
round up, then use this:

Function Round10(n)
Round10 = 10 * Int(n / 10 + 1)
End Function

Tom Lake
 
Meangene,

Or, a variation (improvement?) on the theme...
(([YourNumber]-1)\10+1)*10
 
With the exception of one, thanks for everyones helpful and polite answers!
Two of the suggested solutions work well.
 
Or, to work with both positive and negative numbers:

-Sgn(MyNumber)*Int(-Sgn(MyNumber)*MyNumber/10) * 10
--

Ken Snell
<MS ACCESS MVP>
 
Ken,

I would regard "rounding up" to be:
34 rounds up to 40
-34 rounds up to -30

No?
 
I have found that everyone's "definition" of rounding up varies, often
depending upon the context.. so I just assume the "up" means in the
direction of the larger magnitude of the number, not the value of the number
< g >.
 
Fair enough. Anyway, just for fun, this works for *my* definition of
"up"...

((MyNumber+(MyNumber>0))\10-(MyNumber>0))*10

Maybe it's the Southern Hemisphere <g>
 
Steve Schapel said:
Fair enough. Anyway, just for fun, this works for *my* definition of
"up"...

((MyNumber+(MyNumber>0))\10-(MyNumber>0))*10

Maybe it's the Southern Hemisphere <g>

Best explanation for this that I've ever heard!

< BG >
 
Back
Top