|
Subject:
|
Code not calculating correctly in all the records
|
|
Posted By:
|
bright_mulenga
|
Post Date:
|
1/25/2007 2:15:05 AM
|
I have put VBA code in the form current to be executed when the form is started. Now, I have found that the code is executing correctly in some records but not in others.I have 18 record. What is the problem. e.g as I navigate through the records by the forms. In some it calculates correctly but in others not Help Tax bands are as follows per income category Less than 260,000 = tax is 0 TAX BAND 1 The next 720,000 = taxed at 30% TAX BAND 2 The next 4,000,000 = taxed at 35% TAX BAND 3 Any excess is taxed at 37.5% TAX BAND 4
The following is the code I used Where ‘e’ is the total income (txtTOTALINCOME) Total tax =txtPAYE represented by ‘J’ PAYE is the field in the table
‘TAX BAND 1 If e < 260000 Then k = 0 tax1 = k Else ‘(260,000+720,000) TAX BAND 2 If e > 980000 Then f = (30 / 100) * 720000 tax2 = f 'Else ‘TAX BAND 3 If e < 4980000 Then i = (e - 980000) g = (35 / 100) * (e - 980000) tax3 = g j = (g + f) 'End If ' txtPAYE = j 'PAYE = txtPAYE 'End If Else ‘TAX BAND 4 If e > 4980000 Then h = (37.5 / 100) * (e - 4980000) tax4 = h j = (f + h + g) txtPAYE = j PAYE = txtPAYE 'Pension Pension Contribution e = txtTOTALINCOME p = txtNAPSA '(Pension contribution) n = txtstatus p = (5 / 100) * e '(Calculated at 5% of total income) txtNAPSA = p If e >= 4135000 Then txtNAPSA = 206842.8 '(maximum pension Contribution allowed) If txtstatus = "N" Then (Contribution exemption for anyone aged 55yr txtNAPSA = 0 NAPSA = txtNAPSA 'to Calculate the total deductions j = txtPAYE p = txtNAPSA q = txtPLEVY d = txtTOTALDEDUCTIONS s = TXTADVANCE d = (j + p + q + s)
txtTOTALDEDUCTIONS = d TOTALDEDUCTION = txtTOTALDEDUCTIONS 'to calculate the Netpay o = txtnetpay o = e - d txtnetpay = o txtnetpay = txtTOTALINCOME - txtTOTALDEDUCTIONS netpay = txtnetpay
When I load the form, I expect to calculate the Personal tax, Pension contribution all the way to NET PAY Note: I have include the explanatory notes just for clarification on the meaning of certain items.
Bmulenga
|
|