Results 1 to 3 of 3
  1. #1
    mgmirvine is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    7

    Question Query Not Returning Null Fields

    First, thank you for reading my post. I'm familiar with Access, but definitely not a pro. So, I'd like to apply criteria to a query, such that (1) all records are returned if no input provided, or (2) only the records matching input. My expression looks like this:



    Like "*" & [Forms]![CodeSearchForm]![Code] & "*"

    So when a user types some info into the CodeSearchForm, the query should return the records that match that code. That works fine, but problem is when user leaves the input blank, it only returns not null records.

    I've searched and searched for a solution this this. Modifying the expression with "OR Is Null" won't work, because then when the user does input criteria, it will return the codes that match AND the null records.

    Any help you can provide is greatly appreciated. Thank you

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Is there a reason not to use nz(var,"") to force the query to treat a null

    field as "". I had to resort to that recently, but there wasn't a logical reason not to do it. If you have a real distinction between null and "", then it may not work for you.
    To further clarify, I placed a calculated variable in a field in the query design:
    A:nz([A],"")

  3. #3
    mgmirvine is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2011
    Posts
    7

    Thumbs up It worked!

    hertfordkc, thank you so much for this tip! It totally worked.

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

Similar Threads

  1. Query not returning null values
    By janelgirl in forum Access
    Replies: 5
    Last Post: 10-11-2011, 10:31 AM
  2. Query search wont display null fields
    By Coffee in forum Queries
    Replies: 2
    Last Post: 08-08-2011, 09:00 AM
  3. make query fields not display if null data
    By rivereridanus in forum Queries
    Replies: 1
    Last Post: 07-05-2011, 08:19 AM
  4. Query returning fields not chosen
    By cam2era in forum Queries
    Replies: 5
    Last Post: 03-23-2011, 11:43 AM
  5. Replies: 2
    Last Post: 03-23-2011, 11:13 AM

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