Results 1 to 4 of 4
  1. #1
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85

    Another equation question

    Okay I have to assign a value to a [field2] depending on the number in the [field1] it will give me a rating.

    Between 0 and 5.25 it will give me a rating of 20
    Between 5.25 and 5.499 it will give me a rating of 5
    Between 5.499 and 6.401 it will give me a rating of 0
    Between 6.401 and 6.9 it will give me a rating of 5
    Anything greater than 6.9 will give me a rating of 20

    I put in the equation below and it works and gives me a rating of 20 back if I'm above 6.9 and below 5.25 but it will not give me the rating 5 or 0 between the other ranges.



    =IIf([pH2]>0,20,IIf([pH2]>5.25,5,IIf([pH2]>5.499,0,IIf([pH2]>6.401,5,IIf([pH2]>6.9,20,0)))))


    Any help would again be much appreciated!

    Brad

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    The IIf() will drop out as soon as a test is true, so you'd want to reverse your tests. You might find Switch() easier to work with, or putting the ranges and values in a table, which would be more maintainable in the long run.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    I agree with Paul
    = IIf([x] > 6.9, 20, IIf(x > 6.401, 5, IIf([x] > 5.499, 0, IIf([x] > 5.25, 5, IIf([x] > 0, 20, 0)))))

    He's just quicker with the answer.

  4. #4
    stryder09 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2011
    Posts
    85
    Perfect thanks guys.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. time equation in form
    By WCR in forum Forms
    Replies: 2
    Last Post: 01-05-2011, 11:13 PM
  2. Storing an Equation in Table
    By tmedler in forum Programming
    Replies: 0
    Last Post: 03-09-2009, 09:25 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums