Results 1 to 3 of 3
  1. #1
    Romio is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2015
    Posts
    8

    IIf statement with or/and

    I have the following situation



    Select query with tons of formulas and calculations goes sluggish
    I started some optimization, and I am trying to remove as much calculated fields as I can

    One field of the query contains info about personal ID code. The first character in the code comes from gender> 1,3,5 for male and 2,4,6 for women
    The form that calls the query provides info about gender in a Gender field
    If gender is not selected, parameter is 0
    If male > 1
    If female > 2

    For 0 condition, all records should be dispalyed
    For 1, only codes that starts with 1,3 or 5
    For 2, only records that starts with 2,4,6

    I can easily do it using an Expression field, but I would like to simplify the query and remove the calculated field and use a filterin formula in the ID field [CNP]

    I tried this, but it doesn't work

    Like IIf([Forms]![Cautare_Membru_Frm].[Gender]=0,"*",
    IIf([Forms]![Cautare_Membru_Frm].[Gender]=1,("1" & "*") Or ("3" & "*") Or ("5" & "*"),("2" & "*") Or ("4" & "*") Or ("6" & "*"))

    What am I doing wrong here?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922

  3. #3
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Answered quite nicely in the cross posted thread.

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

Similar Threads

  1. Replies: 11
    Last Post: 04-29-2015, 01:38 PM
  2. use if statement or something else
    By billcar2006 in forum Access
    Replies: 3
    Last Post: 03-09-2015, 03:34 PM
  3. If statement
    By cbende2 in forum Access
    Replies: 6
    Last Post: 08-04-2014, 02:17 PM
  4. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  5. Replies: 7
    Last Post: 08-17-2011, 01:49 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