need said:
In need to roundup a simple markup formula for pricing. Does Access permit
the rounding up to the nearest $10?
In:
http://groups.google.com/group/microsoft.public.access/msg/d1b5b764da495d5e
Van T. Dinh
MVP (Access)
states:
You can use:
- Int( - [YourNumber] )
e.g.:
?-Int(-3.2)
4
That was a very clever idea. Graphing Int(x), flipping everything
across the Y axis (Right/Left) then flipping everything across the X
axis (Up/Down) shows that that ceiling function is good for all values of X.
Now, adjust the function so that it rounds up to the nearest 10:
-10 * Int(-X / 10#)
The '/ 10#' scales X up by a factor of 10 since 10 units in the new
coordinate system corresponds to 1 unit in the old coordinate system.
The '10 *' scales Y up by a factor of 10 since on the other side of the
equation it looked like Y/10.
Sample calculations:
-10 * Int(-32 / 10#) = -10 * 4 = 40 (32 -> 40)
-10 * Int(--5 / 10#) = -10 * 0 = 0 (-5 -> 0)
-10 * Int(--12 / 10#) = -10 * 1 = -10 (-12 -> -10)
-10 * Int(CCur(12) / 10#) = -10 * 1 = -1 (-$12 -> -10)
Perhaps throw in an NZ() around the field name to guard against Null
field values.
James A. Fortune
(e-mail address removed)