Full Version: Rounding To The Nearest Penny.
UtterAccess Forums > Microsoft® Access > Access Forms
This is what I have:

Contorls Names:

RegHours:(Format: Standard, Decimal Places: Auto)
CurrHrlyRate:(Format: Currency, Decimal Places: Auto )
RegRateEarnings:(Format:Currency , Decimal Places: Auto, Control Source: = (RegHours * CurrHrlyRate)

OTHrs:(Format: Standard, Decimal Places: Auto)
OTRate:(Format: Currency, Decimal Places: Auto )
OTEarnings:(Format:Currency , Decimal Places: Auto, Control Source: =Nz([OTHours])*Nz([OTRate])

ShiftPremHrs:(Format: Standard, Decimal Places: Auto)
ShiftPremAmt:(Format: Currency, Decimal Places: Auto )
ShiftPremPay:(Format:Currency , Decimal Places: Auto, Control Source: =Nz([ShiftPremHrs])*Nz([]ShiftPremAmt])

TotalEarnings =(Format:Currency, Decimal Places: Auto , Control Source: Nz([RegRateEarnings])+Nz([OTEarnings]+Nz(ShiftPremPay)

Here's the problem:
RegHours = 44.00 CurrHrlyRate = $15.00 RegRateEarnings = $660.00
OTHrs = 24.25 OTRate =$22.50 OTEarnings = $545.63
ShiftPremHrs:= 20.25 ShiftPremAmt =$ 0.50 ShiftPremPay = $ 10.13

TotalEarnings = $1,215.75
I'd like it to show the correct result of =#1,215.76

How would I do this?
Have you tried wrapping ROUND round things

to become
for example?
Yes I've tried but to no avail.
What I want to do is round up if the the decimal in the third position is greater than four.

Example : $10.125 would become $10.13

and $545.625 would become $545.63

So that the addition of these two numbers would result in $555.76 and not $ 555.75
Is your Form bound to a record source, or is this just a calculator ... if it is bound, then you need to change your Datatypes from floating point types (Number/Single; Number/Double) to Currency (NOTE: The Currency datatype is not the same as choosing the Number/Double and using the Currency format!!!!). Set the format to General if the number is not monetary.


Aside from that, it is important to know that Round() uses bankers rounding ... so ...

? Round(545.625, 2)

? Round(545.635,2)

But Format() using scientific ... but the result is Text, so you need to coerce ...

? CCur(Format(545.625, "#.00"))

? CCur(Format(545.635, "#.00"))

RegRateEarnings: CCur(Format(RegHours * CurrHrlyRate, "#.00"))
OTEarnings: CCur(Format(Nz([OTHours],0) * Nz([OTRate],0), "#.00"))
ShiftPremiumPay: CCur(Format(Nz([ShiftPremHrs],0)*Nz([ShiftPremAmt],0),"#.00"))

TotalEarnings: [RegRateEarnings]+[OTEarnings]+[ShiftPremPay]

Or {for a belt/suspenders approach} ...

TotalEarnings: CCur([RegRateEarnings])+CCur([OTEarnings])+CCur([ShiftPremPay])


Resolved Example:

? CCur(Format(44 * 15, "#.00")) + CCur(Format(24.25*22.50, "#.00")) + CCur(Format(20.25*.5, "#.00"))
I'll give this a try and let you know what happens.

Thank you very much for your help.
This is a "lo-fi" version of UA. To view the full version with more information, formatting and images, please click here.