Results 1 to 7 of 7
  1. #1
    Join Date
    Dec 2002
    Location
    United States
    Posts
    2

    Lightbulb Unanswered: Problem with IIf Statment Resloved

    Taking out the quotations worked. I got the results I expected. Thanks for the info. All I have to say is DUH!!! I should have known better.


    I am using an IIF statement that scores a person based on the result of Income/Rent. My problem is: if the income is greater than 9.9 times the rent it returns the 2 instead of the 6. What do I do to fix this?


    RI: IIf([ric]>="3","6",IIf([ric]="0","0","2"))

    RIC = Rent to Income Calculated

    Example
    Rent = 450.00
    Income = 6000.00
    RIC=6000.00/450.00 = 13.3

    13.3 being the condition in the IIf statement

    If the calculated answer is less than or equal to 9.9 the IIF statement works fine. If it is equal to or greater than 10.00 it does not work correctly.
    Last edited by cskehan; 12-20-02 at 13:15.

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: Problem with IIf Statment

    Originally posted by cskehan
    I am using an IIF statement that scores a person based on the result of Income/Rent. My problem is: if the income is greater than 9.9 times the rent it returns the 2 instead of the 6. What do I do to fix this?


    RI: IIf([ric]>="3","6",IIf([ric]="0","0","2"))
    I think we will need more of the code.
    where is [ric] calculated?

    Is there more code and if so can you post it for us?
    Jim

  3. #3
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    get rid of all of the quotes.

    [ric] >= "3" is doing an alpha compare NOT a numeric compare.

    100000 is less than 3 in an alpha sort.

    izy

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    that of course depend on whether ric is numberic of text, i would of thought numeric but you can never tell
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by m.timoney
    that of course depend on whether ric is numberic of text, i would of thought numeric but you can never tell
    Im guessing we need a bit more info

  6. #6
    Join Date
    Dec 2002
    Location
    Préverenges, Switzerland
    Posts
    3,740
    trust me - it's the quotes.

    see the original question:

    RIC=6000.00/450.00 = 13.3 <--- ric is a number

    If the calculated answer is less than or equal to 9.9 the IIF statement works fine. If it is equal to or greater than 10.00 it does not work correctly <---- in alpha sort 10.00 < 3 < 9.9 so you get precisely the (unwanted) symptoms described


    izy

  7. #7
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    like i said that's the logical conculsion but poeple are so rarly logical, it's almost always best to check but if your right about the suggested problem matches the symptoms that add alot more wieght to your suggestion, which i happen to agree with anyway
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

Posting Permissions

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