Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    IIF and Conversion (Access 2003)

    I have a question regarding an IIF formula in a query:

    Gym Fee: CCur(IIf([Salary]>=25000,25),StrConv(IIf([Salary]<25000,"Free"))

    Gym Fee: CCur(IIf([Salary]>=25000,25,StrConv([Salary]="Free")))

    For those who are equal or greater than 25000 must pay a 25 gym fee, those less than 25000 gym membership is free

    My question regarding the above formula in the query is this. Although the CCur conversts the first portion to Common Currency, how can I get the second portion to see "Free" as a textual answer. Every way I seem to write it doesn't work.
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  2. #2
    5 Star Lounger
    Join Date
    Aug 2004
    Location
    Connecticut, USA
    Posts
    816
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIF and Conversion (Access 2003)

    As you've already noticed, you cannot have mixed data types as the result of your IIF statement.

    You've have to use something that results in the same type of data:

    Gym Fee: IIf([Salary]>=25000,"$25.00","Free")
    or
    Gym Fee: CCur(IIf([Salary]>=25000,25,0))

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIF and Conversion (Access 2003)

    Silly me! Thank you. I didn't even think about converting both to text with quotes. I tried to make it too complicated and it wasn't complicated at all...went against my first rule (simple to extreme)

    Thanks a lot for the speedy response Mike.
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

  4. #4
    New Lounger
    Join Date
    Apr 2008
    Location
    Jacksonville, North Carolina, USA
    Posts
    22
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIF and Conversion (Access 2003)

    You beat me to the punch.
    Charlie

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Jacksonville,NC, USA
    Posts
    705
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: IIF and Conversion (Access 2003)

    <img src=/S/mice.gif border=0 alt=mice width=50 height=25> I did! Didn't want it to keep me awake tonight! (ha)
    NMP <img src=/S/cool.gif border=0 alt=cool width=15 height=15>

    If you can't convince them, confuse them. - Harry Truman <img src=/S/scratch.gif border=0 alt=scratch width=25 height=29>

Posting Permissions

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