# Thread: if statement or switch case

1. Registered User
Join Date
Apr 2008
Posts
5

## Unanswered: if statement or switch case

I am working on a tax calculation program. i want to use multi if statement in the manner below:-

if sex=Male
and income>110000 and income<=150000
then tax=(income-110000) *10

elseif if sex=male
and income>150000 and income<=250000
then tax=(income-150000)*20+4000

elseif sex = male
and income>250000
then tax(income-250000)*30+24000

Please tell what will be the proper syntax for this problem in access and where to write this code.

2. Registered User
Join Date
Apr 2004
Location
metro Detroit
Posts
634
What if sex<>male?

Where to write the code depends on what your doing with the results.

3. Registered User
Join Date
Apr 2008
Posts
5
Actually there are three categories, Male, Female and Senior Citizen.

Different parameters for tax deduction for each category.

I want to save the results in table. I dont know the very deep access. I just used the AfterUpdate event to do my other calculations.

4. Registered User
Join Date
Apr 2004
Location
metro Detroit
Posts
634
You could use either nested selects or a select with if statements. I'd determine sex first, then determine income level within sex. You could perform these calculation AfterUpdate as well.

5. King of Understatement
Join Date
Feb 2004
Location
One Flump in One Place
Posts
14,912
I would go for option C - you didn't give an option C, but I am proposing one (with the benefit of the advice of an excellent author)
http://weblogs.sqlteam.com/jeffs/arc...2/10/9002.aspx

To cover one really good reason for this - what happens when the boudaries change (which one day they will)?

6. Registered User
Join Date
Apr 2008
Posts
5
Rogue, can you give me the full syntax for this. I will be very thankful to you.

7. Registered User
Join Date
Apr 2004
Location
metro Detroit
Posts
634
There's a good example of a select case statement in VBA help. Take a bash and post back if you have problems. I would also take a look at the link that Pootle posted. Since you're dealing with taxes, that's probably the best route to take.

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•