Results 1 to 4 of 4
  1. #1
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48

    IIf Function for expression builder

    Hi,



    I have a column containing 100 different animal names.

    I would like:

    Cat, Dog, Horse, Mouse, Lizzard to retern value 1.

    The rest of the animals shall return value 0.

    What will the function look like in the expressionbuilder?

    Br Bertrand

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Code:
    IIF([Column1]="Cat" or [Column1]="Dog" or [Column1]="Horse" or [Column1]="Mouse" or [Column1]="Lizzard",1,0)
    Alternatively, you could make a lookup table with twp columns, containing these names in one column, and a value of "1" in the second column.

    Then, you could do a Left Join between your main table and this lookup table, returning the value of column 2. You can use the NZ function to convert the unmatched nulls to zero, i.e.
    Code:
    Nz([Field2],0)

  3. #3
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    A better way: IIF([column1] In ("Cat","Dog","Horse","Mouse","Lizzard"),1,0)

  4. #4
    Bertrand82 is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2012
    Posts
    48
    Thank you for excellent support.

    Later IŽll check "Left Join between your main table and this lookup table"

    Br

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

Similar Threads

  1. Expression builder help
    By jigg14 in forum Forms
    Replies: 1
    Last Post: 03-19-2012, 09:47 AM
  2. Expression Builder not there
    By schnuber in forum Access
    Replies: 1
    Last Post: 02-17-2012, 01:17 AM
  3. expression builder
    By tonyl in forum Access
    Replies: 3
    Last Post: 11-26-2011, 12:00 AM
  4. Expression builder
    By PJ_d_DJ in forum Access
    Replies: 2
    Last Post: 02-24-2011, 03:38 AM
  5. Expression Builder
    By mistaken_myst in forum Access
    Replies: 2
    Last Post: 05-07-2008, 01:30 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