Results 1 to 4 of 4
  1. #1
    Shameen is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    May 2017
    Posts
    1

    Exclamation Conditional Formula by using IIF

    Hi,



    I am struggling with the following condition on to the query table. Can any one please help to complete the following conditions. I have tried number of times, but it returns strange results.

    DisplayText: IIf([Mark Obtained - Practical]<5,"FAIL",IIf([Mark Obtained - Practical]>5<6.5,"Grade C - Pass")).............?

    Conditions to include:


    • When score <4.9 ‘Fail’
    • When score >5<6.5 ‘Grade C – Pass’
    • When score>6.6<7.5 ‘Grade B – Pass’
    • When score >7.6<8.5 ‘Grade A – Pass’
    • When score >8.6=10 ‘Grade A+ - Pass’


    Regards,
    Shameen

  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,652
    Your syntax is wrong, but since the tests are applied in order, simply test for less than 4.9, less than 6.5, etc.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,929
    I concur with Paul's comments but also suggest using the switch function rather than the iif function for readability

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    IIf([Mark Obtained - Practical]>5 and [Mark Obtained - Practical]<6.5,"c","")

    or make a custom function for queries to use. Paste the code in a module.....
    In the query :
    GetGrade([Mark Obtained - Practical])

    Code:
    Function getgrade(pvPts)
    
    Select case pvPts
      Case  >5 and <6.5 
           GetGrade =   ‘Grade C – Pass’
    Case >6.6 and <7.5
         GetGrade =‘Grade B – Pass’
    When score >7.6and <8.5
          GetGrade =‘Grade A – Pass’
    Case  >8.6 and <=10
        GetGrade =‘Grade A+ - Pass’
    Case else
      GetGrade =‘Fail’
    end select
    end function

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

Similar Threads

  1. Replies: 19
    Last Post: 07-13-2015, 10:15 AM
  2. Replies: 41
    Last Post: 05-29-2015, 02:58 PM
  3. Conditional formula and output
    By blam83 in forum Access
    Replies: 1
    Last Post: 01-16-2015, 03:29 PM
  4. Replies: 6
    Last Post: 05-26-2013, 09:10 PM
  5. Conditional Formula?
    By nellolopez in forum Access
    Replies: 1
    Last Post: 05-05-2011, 06:17 AM

Tags for this Thread

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