Hi Christina,
Sounds like a good place to be!
To do the computations on the form do something like this (you will
need to adjust for your actual fields and data): Right-click on the regular
hours worked text box and choose Properties. Go to the Events tab and click
in the After Update event line. You will get a down arrow and a button with
three periods. Click on the button and choose Code Builder. Because you
will probably need to call the same code from several after update events,
such as also on an overtime hours worked field, in this one's event just call
out to another function that you will write shortly. So a single line:
CalculateGrossPayTaxesNetPay
Repeat the process for the overtime hours text box.
Then in the code window at the bottom create the new subroutine to do
the calculations:
Private Sub CalculateGrossPayTaxesNetPay()
[txtRegularPay] = Nz([txtRegularHoursWorked], 0) *
[txtThisPersonsRegularPayRate]
[txtOvertimePay] = Nz([txtOvertimeHoursWorked], 0) *
[txtThisPersonsOvertimePayRate]
[txtGrossPay] = [txtRegularPay] + [txtOvertimePay]
[txtIncomeTaxes] = DLookup("TaxAmount", "IncomeTaxTable", [txtGrossPay]
& " between [PayRangeLow] and [PayRangeHigh]")
[txtSocialSecurityTaxes] = DLookup("TaxAmount",
"SocialSecurityTaxTable", [txtGrossPay] & " between [PayRangeLow] and
[PayRangeHigh]")
[txtNetPay] = [txtGrossPay] - [txtIncomeTaxes] - [txtSocialSecurityTaxes]
End Sub
This assumes that the regular pay and overtime pay rates for the person
are available in the form. If not, you could use the DLookup function to get
them using the person's ID number.
If doing it in the queries, you do not need to join the fields between
the main hours worked/pay table and the tax tables because you are "joining"
them with the conditions you enter in the criteria line.
Hope that makes sense,
Clifford Bass
Christina said:
I am in Belize, that small English speaking country between Guatemala,
Mexico, and Honduras.
I like the idea of the calculation for the tax and social security on the
form. But how do I have it calculate 'after update' Sorry, I need step by
step instructions for this. I have the ITax and Soc Sec tables. I was
trying to do it in a query. I brought the table with the gross pay, and the
income tax table. Do have to join any fields. Dont really know how to
proceed.
Please bear with me.
Thanks