Daryl:
You need to use a rounding function to do this, i.e. round your calc to a
specific number of decimal places, but then in the display format specify a
different set of decimal places. Listed below is a function you can add to
your db to do the rounding, simply wrap your query field's result in this
function as part of the control source for your report and then set the
decimal places to show as two. (Note you may need alias the name of the
report control that this function is used in if it is the same name as the
field that does the calc itself.)
--
Steve Arbaugh
ACG Soft
http://ourworld.compuserve.com/homepages/attac-cg
'=======Begin Code=========
Public Function Round(ByVal Number As Variant, NumDigits As Long, _
Optional UseBankersRounding As Boolean = False) As Double
'Posted by Ken Getz in microsoft.public.access.modulesdaovba
'1998/11/24
'The algorithm can round a number ending with 5 thousandths
'to a number ending with an even-numbered hundredths (banker's rounding).
'e.g. if Bankers = True then Round(8.565 ,2,true) = 8.56
'--------------------
Dim dblPower As Double
Dim varTemp As Variant
Dim intSgn As Integer
If Not IsNumeric(Number) Then
' Raise an error indicating that
' you've supplied an invalid parameter.
Err.Raise 5
End If
dblPower = 10 ^ NumDigits
' Is this a negative number, or not?
' intSgn will contain -1, 0, or 1.
intSgn = Sgn(Number)
Number = Abs(Number)
' Do the major calculation.
varTemp = CDec(Number) * dblPower + 0.5
' Now round to nearest even, if necessary.
If UseBankersRounding Then
If Int(varTemp) = varTemp Then
' You could also use:
' varTemp = varTemp + (varTemp Mod 2 = 1)
' instead of the next If ...Then statement,
' but I hate counting on TRue == -1 in code.
If varTemp Mod 2 = 1 Then
varTemp = varTemp - 1
End If
End If
End If
' Finish the calculation.
Round = intSgn * Int(varTemp) / dblPower
End Function
Daryl said:
I wanna the result of a function shows 2 decimal places while it
calculates the result to 1 decimal place only: