Rouding Function

N

Norman Belanger

Hi

Is there a function that will allow me to round up numbers to 2 decimal
place then cut off the remaining decimal numbers? I have a table where at
times, the numbers require to be devided in 2. Obviously in doing so, odd
numbers will result in more than 2 decimal numbers. Visually it does the
job when I set my table at a fix 2 decimal place or currency format, but the
remaining decimal numbers still remain behind the scene therefore affecting
my sum.

If I have the following number and devide them in two this is what I get:

Original Numbers:
10.23 + 6.43 + 10.54 + 7.56 + 12.35 = 47.11
If devided in 2 they become:
5.115 + 3.215 + 5.27 +3.78 + 6.175 = 23.555
If rounded to 2 decimal the appear as:
5.12 + 3.22 + 5.27 + 3.78 + 6.18 with a result of 23.56 but in reality if
adding the visual numbers the result should be 23.57

I know there's a function in excel for this but somehow can't see it in
Access.

Greatly appreciate the help on this,

Norm
 
P

Phobos

You could use the FIX function:

MyValue: Fix([MyNumber]*100)/100

The only problem with this approach is that it does not round numbers up, it
just chops them off like the Int() function in Excel.

You could use VBA to get round (no pun intended) this though:


Function round(num As Double, dps As Long) As Double
If (num * 10 ^ dps) - Fix(num * 10 ^ dps) >= 0.5 Then
round = Fix(num * (10 ^ dps) + 1) / 10 ^ dps
Else
round = Fix(num * 10 ^ dps) / 10 ^ dps
End If
End Function


P
 

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