IIf problems

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kpm_maloney
    New Member
    • May 2006
    • 1

    IIf problems

    I am working on a Microsoft Access database for a drug rehab clinic and this is what I need to do.

    I need to beable to take DaysSpent and multiply by cost per day to get CostOfStay. What is throwing me off is there are two pricing catagories(Prov Service) and I cant figure out how to multiply by each pricing catagory.

    Note:when ProvService=02, cost per day is $150, when ProvService=05, cost per day=200

    This is my code so far...


    CostOfStay: IIf([ProvService]=2,([DaysSpent]*150),IIf([ProvService]=5,([DaysSpent]*200)))

    it is just showing #ERROR in the output.

    Any ideas for a modifaction in my IIf statement, or am I going about the problem all wrong and using an IIf statement isnt something I should use in this situation.


    Thanks in advance
    Last edited by kpm_maloney; May 15 '06, 05:28 PM.
  • CaptainD
    New Member
    • Mar 2006
    • 135

    #2
    IIf works like this. IIf(SomethingTo Evaluate, IfTrueValue, IfFalseValue)
    You have two IIf's

    Try:
    Code:
    CostOfStay = IIf([ProvService]=2,([DaysSpent]*150),([DaysSpent]*200)))

    Comment

    • wlc04
      New Member
      • May 2006
      • 70

      #3
      I see you're nesting your IIF's, looks like code is okay except that you're missing the final statement in case neither of the iif's are true:


      CostOfStay: IIf([ProvService]=2,([DaysSpent]*150),IIf([ProvService]=5,([DaysSpent]*200),SOMETHING GOES HERE))

      Comment

      • --Grrrrrr--
        New Member
        • May 2006
        • 2

        #4
        Only other thing that might trip you up is the format of the ProvService field. If it is text you'll probably have to put it in double quotes. i.e. "02" or "05".

        Comment

        Working...