Logo 
Search:

MS Office Forum

Ask Question   UnAnswered
Home » Forum » MS Office       RSS Feeds

Ceiling Function in Access

  Asked By: Erica    Date: Sep 08    Category: MS Office    Views: 3773
  

One question in Access (2003).

I need to accomplish this "rounding" task in MS Access 2003

1) If it is 10.000001 it should be 11
2) If it is 10.999999 it should be 11 too.

In other words, I just need the exact functionality of the CEILING()
function thats available in MS Excel.

I tried Round(expr,significance). But that does not get me what I need.
Also a couple of other functions like int, Cint etc. But in vain. I
posted it in some websites seeking for an answer.

The result of this is important because it is used as one of the
operand in a multiplication operation. So if have 0.3, then i need 1
and not a 0.

Share: 

 

4 Answers Found

 
Answer #1    Answered By: Cay Nguyen     Answered On: Sep 08

: One question  in Access (2003).
:
: I need to accomplish this "rounding" task in MS Access 2003
:
: 1) If it is 10.000001 it should be 11
: 2) If it is 10.999999 it should be 11 too.
:
: In other words, I just need the exact functionality of the CEILING()
function  thats available in MS Excel.

I am not familiar with the Access, but I have run into a similar
problem in computer languages which do not offer a ceiling function.
Try something like this. "int" is the integer function available in
most languages. (I didn't test this on negative numbers.)


' Ceiling
If number > int(number) Then number = int(number) + 1

 
Answer #2    Answered By: Corbin Jones     Answered On: Sep 08

I thing function  INT() can help you.

**********
Dim b As Double
Dim i As Integer
b = 10.000001
i = Int(b)

If i = b Then
i = i +1
End If
*********

 
Answer #3    Answered By: Taylor Evans     Answered On: Sep 08

The simplest version I think would be:



Public function  Ceiling(ByVal X As Double) As Double

Ceiling = Int(X) - (X - Int(X) > 0)

End Function



Watch out for negative numbers, as David Smart suggested. This function
would round them up.

 
Answer #4    Answered By: Benjamin Simpson     Answered On: Sep 08

Plenty of hits with a Google search. This one for instance ...

http://www.tek-tips.com/faqs.cfm?fid=5031

A lot depends on just how accurately you want to simulate Excel's Ceiling.
It takes two parameters, and they must both be of the same sign, and it
rounds away from zero (i.e. negative numbers become more negative).

 
Didn't find what you were looking for? Find more on Ceiling Function in Access Or get search suggestion and latest updates.




Tagged: