if statement or switch case

Discussion in 'MS Access' started by edreamers, Apr 23, 2008.

  1. edreamers

    edreamers New Member

    Joined:
    Nov 28, 2006
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    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.

    Thanks in advance.
     
  2. DonCarmelo

    DonCarmelo New Member

    Joined:
    Dec 13, 2009
    Messages:
    3
    Likes Received:
    0
    Trophy Points:
    0
    Hi

    You would have to create a module by clicking on module on the left of the window. This allows you to write vba (Visual Basic for Applications) code. Create a function called TaxCalc or anything else you want to name it and make it public. That way it can be reached by queries, etc.

    Public Function TaxCalc(Income as single) as single

    your code here

    end function

    This accepts the income as a parameter and calculates a result. If you name the result TaxValue, your last statement in the function would be

    TaxCalc=TaxValue
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice