Results 1 to 2 of 2
  1. #1
    SgtSaunders69 is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    17

    Passing criteria "NULL" or "IS NOT NULL" to a query

    I want to pass the criteria "NULL" or "IS NOT NULL" to the underlying query in a report from a field on a form where all criteria for the particular report is selected before running the report. Typicially the procedure I use is to place the name of the control from the form in the criteria field of the query... example... if I'm providing a date to the query, I put a date field on the form and put the full name of the field "forms!myform!fieldname" in the criteria field of the query underlying the report. This is pretty bullet proof, except when I want to pass a value of "null", or "not null" as the criteria for a given field in the query. How can I set up a combo box, or command button, or selection box to feed the values "NULL" or "NOT NULL" as criteria the underlying query?



    Thanks all..

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,928
    If the combobox RowSource is a lookup table with no nulls, you can create a Null value in the RowSource with a UNION. I don't see any way to get the opposite.

    SELECT fieldname FROM tablename UNION SELECT Null FROM tablename;

    An alternative to the query parameter input is to construct the filter criteria in VBA code and use the WHERE clause of DoCmd.OpenReport to pass filter criteria to the report.
    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. Replies: 3
    Last Post: 12-20-2011, 08:41 AM
  2. Replies: 1
    Last Post: 10-15-2011, 01:12 PM
  3. StrComp causing "Invalid use of Null" error
    By sephiroth2906 in forum Programming
    Replies: 5
    Last Post: 09-15-2011, 07:06 PM
  4. Update query from form "invalid use of null"
    By Lady_Jane in forum Programming
    Replies: 4
    Last Post: 08-16-2011, 01:37 PM
  5. Convert null to "" in Access
    By isaac_2004 in forum Access
    Replies: 1
    Last Post: 12-04-2009, 06:50 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