Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
|
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old January 25th, 2007, 03:15 AM
Authorized User
 
Join Date: Nov 2005
Posts: 27
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code not calculating correctly in all the records

 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
__________________
Bmulenga





Similar Threads
Thread Thread Starter Forum Replies Last Post
ForeColor doesn't display correctly. goldenstate ASP.NET 2.0 Basics 3 February 16th, 2007 12:36 PM
Hello User, not working correctly? Neotriple BOOK: Beginning Visual Basic 2005 ISBN: 978-0-7645-7401-6 1 October 5th, 2006 11:39 AM
Starting Off Correctly... JESwan XML 0 April 28th, 2005 08:01 AM
No error but not working correctly! Adam H-W Javascript 7 November 10th, 2003 09:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.