Results 1 to 3 of 3
  1. #1
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71

    Query Criteria IIF statement - using Not Equal when True/False

    I have been searching for an hour without success for an answer to my question.



    I have an iif statement as a criteria in a query. When the test is true then I want to show all records where the field is NOT equal to "none", otherwise show me everything. I'm using the following as my iif:

    Code:
    Like IIf([forms]![DefectNotificationReviewF]![DefectFilterOpt]=2,<>"None",[NotificationNumber])
    [NotificationNumber] is the field name. When I pull out the <> it shows me all the records with NONE in the field. However, for my purpose I need to see the records without NONE. Those records contain unique number strings so I can't search for a single item. I need to ignore the NONE entries to show the set of records.

    Can anyone point me in the right direction?

    Thanks,
    Dave D.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    LIKE operator is only useful with wildcard and with text type fields, not numbers.

    The operator (LIKE, <>, =, etc) cannot be dynamic. Mixing LIKE with another operator won't work.

    I never use dynamic parameterized queries. I prefer VBA to construct filter criteria. Review: http://www.allenbrowne.com/ser-62.html

    If you must use parameterized query, then calculate a field in query:

    MyCriteria: IIf([forms]![DefectNotificationReviewF]![DefectFilterOpt]=2 AND [NotificationNumber]="None",False,True)

    Filter criteria under that field: True
    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
    dcdimon's Avatar
    dcdimon is offline Advanced Beginner
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2013
    Location
    Bradenton, FL
    Posts
    71
    I ended up making a calculated field in the query - as June7 suggested - about 10 minutes after I posted this question. I think I needed to take a break from staring at the query builder because as soon as I went back in I thought of it.

    I had toyed with the idea of using a SQL VBA script, but I wanted something that i could easily modify and use some form data to filter with. The VBA was a bit too cumbersome for that.

    DD

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

Similar Threads

  1. Replies: 8
    Last Post: 10-06-2014, 03:02 PM
  2. Replies: 5
    Last Post: 07-15-2014, 12:00 PM
  3. Replies: 7
    Last Post: 05-30-2013, 04:22 PM
  4. Replies: 2
    Last Post: 10-29-2012, 11:28 AM
  5. Replies: 7
    Last Post: 01-11-2012, 12:24 PM

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