Rounding a Value (1 Viewer)

BLeslie88

B Leslie
Local time
Today, 21:58
Joined
May 9, 2002
Messages
228
Easy One I Think!!!!

Alright.... I am doing work for my accounting department. They care alot about pennies... :eek:

So here is my delema....

Text Box face values visible to eye:
$0.70
$10.55

Actual Values :
$0.6962
$10.5456

Text Box Result: (Adds actual values)
$11.24

Need the result as shown in text text boxes: (Visual values, I must drop decimal values past 2)
$11.25
 

David R

I know a few things...
Local time
Today, 15:58
Joined
Oct 23, 2001
Messages
2,633
Are the fields saved as currency?

I'm trying to figure out why they have extra digits to begin with...are these calculated amounts?

You should be able to get the result you want with Round() and or Int(). (Hint: If you multiply it by 100 and take the Int() value, then divide it by 100, you will strip off those extra fractional pennies. However that would make .6956 into .69, not .70
 

BLeslie88

B Leslie
Local time
Today, 21:58
Joined
May 9, 2002
Messages
228
Yes...

It is a percentage such and 0.0725% added the gross salary.... I am to sum all these values... I have tried the CDbl(); CInt(); Rnd(); Fix() Functions..... They are not helping....... And these are report calculations done on the report not values from a table unfortunately... This is our payroll system, I would have to build tables myself and this would require more runtime for the users, this is simple query extracts and built reports....
 
Last edited:

Fornatian

Dim Person
Local time
Today, 21:58
Joined
Sep 1, 2000
Messages
1,396
Do any of these functions meet your requirements?

Code:
Function Round2(x)
'
' Rounds a number to 2 decimal places
' Uses arithmatic rounding
'
  Round2 = Int(x * 100 + 0.5) / 100
End Function

Function Round2C(x)
'
' Rounds number to 2 decimal places
' Uses arithmatic rounding
' Designed for use with Currency values
'
  If IsNull(x) Then
    Round2C = Null
  Else
    Round2C = CCur(Int(x * 100 + 0.5) / 100)
  End If
End Function

Function Round2CB(x As Variant) As Variant
'
' Banker's rounding of Currency to 2 decimal places.
'
Dim Temp As Currency, ITemp As Currency, Digit As Integer
  If IsNull(x) Then Exit Function
  Round2CB = CCur(x / 100) * 100
End Function

Function RoundN(x, N As Integer)
'
' Rounds a number to N decimal places
' Uses arithmatic rounding
' N should be in the range 0-10 for proper results
'
Dim Factor As Long
  Factor = 10 ^ N
  RoundN = Int(x * Factor + 0.5) / Factor
End Function
 

Users who are viewing this thread

Top Bottom