Results 1 to 4 of 4
  1. #1
    Greg.Terry is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Location
    Huntsville, AL
    Posts
    2

    Using Form Variable in Query Criteria

    I have a query with a column that is a Yes/No type. I'm trying to get the criteria set via a form variable such that it returns either "No" items, or All items both "Yes" and "No."



    Please help!

    Thanks!

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    what's your first attempt? post the sql

  3. #3
    Greg.Terry is offline Novice
    Windows Vista Access 2007
    Join Date
    Apr 2011
    Location
    Huntsville, AL
    Posts
    2
    Not actually my first attempt, but the other have failed also. I derived this criteria approach from a post on another site.

    SELECT SMDP_SOP_Query.[FOS notifies PDMO of completion], SMDP_SOP_Query.DocumentID, SMDP_SOP_Query.[PMO ADM log Subject or Title of Document], SMDP_SOP_Query.ID
    FROM SMDP_SOP_Query
    WHERE (((SMDP_SOP_Query.[FOS notifies PDMO of completion])=IIf([Forms]![SMDP_SOP_Form]![RecControl].[Value]=-1,-1,([SMDP_SOP_Query].[FOS notifies PDMO of completion])=0 Or ([SMDP_SOP_Query].[FOS notifies PDMO of completion])=-1)))
    ORDER BY SMDP_SOP_Query.[FOS notifies PDMO of completion] DESC , SMDP_SOP_Query.DocumentID;

  4. #4
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    your where clause is incorrect. this one is correct:

    Quote Originally Posted by Greg.Terry View Post
    SELECT SMDP_SOP_Query.[FOS notifies PDMO of completion], SMDP_SOP_Query.DocumentID, SMDP_SOP_Query.[PMO ADM log Subject or Title of Document], SMDP_SOP_Query.ID
    FROM SMDP_SOP_Query

    WHERE (((SMDP_SOP_Query.[FOS notifies PDMO of completion])=IIf([Forms]![SMDP_SOP_Form]![RecControl]=-1,-1,0)))

    ORDER BY SMDP_SOP_Query.[FOS notifies PDMO of completion] DESC, SMDP_SOP_Query.DocumentID;

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

Similar Threads

  1. Replies: 3
    Last Post: 10-15-2010, 11:17 AM
  2. Form-Query Variable line Headers
    By Cheshire101 in forum Forms
    Replies: 2
    Last Post: 09-13-2010, 12:38 PM
  3. Refering to variable form names inside a variable
    By redpetfran in forum Programming
    Replies: 2
    Last Post: 05-21-2010, 01:39 PM
  4. Query criteria in a form
    By sefiroths in forum Queries
    Replies: 1
    Last Post: 12-23-2009, 05:15 AM
  5. Variable Criteria
    By JamesLens in forum Queries
    Replies: 0
    Last Post: 01-02-2009, 04:55 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