Currency rounding issues

O

Odewallrus

Here is a problem that I am having that seems very simple to me
obviously I am missing something. If some one could help?

I have a house charge field that allows a user to charge all or
portion of a bill. In the AfterUpdate event of the house_charge fiel
is the following code. The problem is that if I enter a house charg
amount that is equal to the grand total, in most cases I get th
message "A House Charge posted against this work order cannot b
greater than the Grand Total, or left blank." I believe that it has t
do with the totals being rounded up and thus they are actually les
that the house_charge amount. Below I turned on 3 decimal places t
show the problem, but in my database I have set currency and 2 decima
places in all forms, tables and queries. Below I am trying to input
value of $340.21 into the house_charge field.

code:
**************************************************

If Me.House_Charge_Amount.Value <
Forms![Customer_information_Form]![Work_Order_Subform]![Work_Order_Customer_Total_Subform]!Grand_Tota
Then
Me.Other_Payment.SetFocus
Me.House_Charge_Amount.Enabled = False
Me.House_Charge_Amount.Locked = True
Me.Parent.House_Charge_Balance_Subform.Requery

ElseIf MsgBox("A House Charge posted against this work order cannot b
greater than the Grand Total, or left blank.", vbOKOnly, "House Charg
Help") = vbOK Then
Me.House_Charge_Amount = "0"
Me.House_Charge_Amount_Button.SetFocus
Me.House_Charge_Amount.Enabled = False
Me.House_Charge_Amount.Locked = True

End If


Work_Order_Customer_Total_Subform:
***************************************************
(with 2 decimal places set)
Labor $20.95
Parts $300.00
Sub Total $320.95
Tax $19.26
Grand Total $340.21

(with 3 decimal places set)
Labor $20.95
Parts $300.00
Sub Total $320.95
Tax $19.257
Grand Total $340.20
 
A

Allen Browne

The problem appears to be with the calculation of tax.
At whatever point you calculate the tax, it needs to be rounded to 2 places:

Assuming a 6% tax, set it to:
= Round(CCur(Nz[Sub Total],0) * .06), 2)

If you are using Access 97 or earlier, there is no Round() function, but you
can grab one from:
http://www.mvps.org/access/modules/mdl0054.htm
 

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