ROUNDING UP TO THE NEXT WHOLE NUMBER

V

vvwilson

I am in the construction industry and am looking to create a form and
or report that rounds a numeric value up to the nearest whole number.
For example 5.3 should read 6, 5.6 should read 6. This field will be
used to calculate material cost so it is very important to show enough
material. Please Help!
 
J

John Spencer

You can round up to a whole number using

Int(-[YourNumber])

So you can write a simple function like below and pass in any positive
number and round it up.

Public Function fRoundUp(aNumber)
If IsNumeric(aNumber) = False then
fRoundUp = aNumber
Else
fRoundUp = -Int(-aNumber)
End If
End Function

--
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
..
 
J

John Nurick

Try this:

-Int(-X)

where X is the value you want to round. But if there is any possiblity
that you will be passing it a negative value, make sure it behaves as
you expect.
 
J

John Spencer

What John Nurick said.

If missed putting the negative sign in front of the int. My post should
have read
-Int(-[YourNumber])

I did get it correct in the function.

'====================================================
John Spencer
Access MVP 2002-2005, 2007
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 

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

Top