Results 1 to 4 of 4
  1. #1
    Only4Access is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    38

    IIF in form query

    Hello Everyone,

    I am newbie in Access. This will be very simple for you guys, but for me it's not.

    I have a table, tbl1. I am making a search form which I got through this Site

    In the form there is a compo with 3 drop down, All, Pending, Closed. In tbl1 there is a field called "Status". So basically I am trying to retrieve data based on comp selection. In Query I tried under "Status" field 'Criteria' area,

    IIF([Forms]![Search]![SearchStatus]="All",Like "*",[Forms]![Search]![SearchStatus])

    If I select 'All' nothing pulled, but for 'Pending' & 'Closed' works.

    How can I fix this. If I select 'All' pull everything <>"" in "Status" field.



    Thank you for your time.

    Raj

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,771

    Wildcard in query conditional WHERE clause

    Think I have encountered this before. Can't get the wildcard to work in IIf criteria. Try this:

    1. Create field in query with expression:
    CriteriaMatch: IIf("All"=[Forms]![Search]![SearchStatus] Or [Status]=[Forms]![Search]![SearchStatus],True,False)

    2. Criteria under this constructed field: True

    If you want to exclude records that don't have any status value (assuming the field will be Null, not empty string - I don't allow empty strings in fields):
    CriteriaMatch: IIf(("All"=[Forms]![Search]![SearchStatus] Or [Status]=[Forms]![Search]![SearchStatus]) AND Not IsNull([Status]),True,False)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    alansidman's Avatar
    alansidman is offline Indifferent
    Windows 7 32bit Access 2007
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,538
    June beat me. Go with her solution

    Alan

  4. #4
    Only4Access is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Feb 2012
    Posts
    38
    Thank you Jun & Alan, works great.

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

Similar Threads

  1. To open a form, sub form if text box entry exist in Query
    By george.vniekerk in forum Programming
    Replies: 2
    Last Post: 08-08-2011, 12:50 AM
  2. Query to only show a value in a form from a query
    By cwwaicw311 in forum Queries
    Replies: 28
    Last Post: 03-27-2010, 02:31 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