Results 1 to 4 of 4
  1. #1
    mikehZA is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2018
    Posts
    1

    Problem using Like operator inside IIF Function

    I have a database containing students from Grade 8 to 12.
    Each Grade can have several classes so Grade 12 could be 12A, 12B, 12C etc.



    I have a form with a Check Box (CheckGrade12) that should determine if a query selects all students or just Grade 12 students.

    If I use the expression below as criteria in the query it works as expected selecting students from 12H or 12G

    IIf([Forms]![Report]![CheckGrade12]=True,"12H","12G")

    But when I use the Like operator to select all students or just Grade 12 students in the criteria as below nothing is selected.

    IIf([Forms]![Report]![CheckGrade12]=True, Like "12*", Like "*")

    Any Ideas where I am going wrong?

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,722

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,522
    dont use it that way, instead use the
    query1 : [Forms]![Report]![CheckGrade12]=True
    query2 : [Forms]![Report]![CheckGrade12]=false

    put the 2 queries in 1 UNION query. No IIF needed.

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,409
    sounds like you are trying to apply this as a query criteria - if so, then you cannot do it this way.

    instead try this mockup of query grid - change names to suit

    Field:___GRADE____[Forms]![Report]![CheckGrade12
    Table:__tblGrades
    Sort:
    Show: X
    Criteria:_Like "12*"______True
    or:___________________False

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

Similar Threads

  1. Replies: 3
    Last Post: 08-17-2018, 07:56 AM
  2. Updating function inside a module
    By keiths in forum Modules
    Replies: 3
    Last Post: 04-05-2017, 08:10 AM
  3. Replies: 1
    Last Post: 07-15-2016, 10:34 AM
  4. Query Criteria Function and Operator List?
    By samanthaM in forum Access
    Replies: 2
    Last Post: 06-03-2012, 04:52 PM
  5. Replies: 4
    Last Post: 04-23-2012, 11:46 PM

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