Results 1 to 3 of 3
  1. #1
    4thangel is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    2

    Criteria field in query set to "no selection"

    I created in the criteria field of a query an conditional statement that should give as result "all entries allowed" when the form field (combobox c1) I refer to is isnull



    SELECT Tbl_dara_test.product
    FROM Tbl_dara_test
    WHERE (((Tbl_dara_test.product)=IIf(IsNull([Forms]![f1]![c1]),(Tbl_dara_test.product) Like "*",[Forms]![f1]![c1])));

    The - like "*" - is not working.
    I tried also "*", "" and the same negative result

    While if I create a text box (t1) in the form with a function =IIf(IsNull([c1]),"*",[c1]) and use in the query
    SELECT Tbl_dara_test.product
    FROM Tbl_dara_test
    WHERE (((Tbl_dara_test.product) Like ([Forms]![f1]![t1])));

    It works!!

    Creating in the from an extra text field seems to me a dirty solution.
    Is there a possibility to create a funtion in the query only?

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    "The Access Web" site has an example of using a parameter to return all records if Null

    http://access.mvps.org/access/queries/qry0001.htm

  3. #3
    4thangel is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jun 2011
    Posts
    2
    Veni, Vidi, Velcro a bit longer please.
    Excellent answer. It works perfectly.

    Thanks

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

Similar Threads

  1. Replies: 6
    Last Post: 07-25-2012, 06:42 AM
  2. Replies: 2
    Last Post: 05-17-2011, 02:40 PM
  3. Replies: 6
    Last Post: 03-10-2011, 11:31 AM
  4. "Group By" causes "ODBC--Call Failed" error
    By kaledev in forum Queries
    Replies: 1
    Last Post: 03-09-2011, 02:43 PM
  5. Replies: 1
    Last Post: 10-19-2009, 02:37 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