Results 1 to 2 of 2
  1. #1
    pdevito3 is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    35

    Access Query/SQL syntax

    Hey everyone,

    I have a checkbox on a form. I want to have the query return everything (*) if the box is checked, and return everything except a value ("Completed" in this case. I can get it to return everything or only fields that are "completed" but not the other way around. I've tried "<>", "!=", "Not = " and many other variations with no luck. What syntax am I missing?

    Working for = completed (Query Builder)
    Code:
    Like IIf([forms]![frmMain]![cbCompleted]=False,"*","Completed")
    Working for = completed (SQL)


    Code:
    WHERE ((tblTrainingRecords.Status) Like IIf([forms]![frmMain]![cbCompleted]=False,"*","Completed"))

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,930
    This means two queries with different criteria.

    If you want everything except "Completed": WHERE Status <> "Completed"

    I don't use dynamic parameterized queries. Review: http://www.allenbrowne.com/ser-62.html
    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.

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

Similar Threads

  1. Syntax Error in my Access SQL Query
    By hellfire45 in forum Access
    Replies: 1
    Last Post: 03-10-2015, 01:40 PM
  2. Replies: 3
    Last Post: 01-29-2015, 07:48 PM
  3. Replies: 10
    Last Post: 11-21-2014, 04:49 PM
  4. Replies: 10
    Last Post: 10-30-2013, 02:06 PM
  5. Access 2007 syntax error in query
    By ivanver in forum Queries
    Replies: 3
    Last Post: 04-23-2011, 09:41 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