Results 1 to 9 of 9
  1. #1
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122

    Is Null

    How to filter a Query in Access for Is Null (not "Is Null")??

    NZ([Value1], Is Null)

    or

    IIF(IsNull(Value1] = True, Is Null, 0)


    Basically, the above two codes generate no results. If I add a "Is Null", it yields no result either because the Field is looking for "Is Null" which is not what the field contains. I want to show everything that is truly Is Null like below but don't know how to code this!

    e.g.


    Click image for larger version. 

Name:	Capture.JPG 
Views:	11 
Size:	10.1 KB 
ID:	38257

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    SELECT * FROM table WHERE RefType Is Null;

    What you show in image looks correct. If this returns no records then none are Null.

    Post example data and full SQL statement attempted.
    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.

  3. #3
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    I was looking for a criteria statement within the query, not from a code executed from the form to this.

    i.e. How to fix this:

    IIF(IsNull(Value1] = True, Is Null, 0) in order for it to generate the result Is Null in the criteria section in the Query??


  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I did not show code from a form. I show the SQL statement you can see in query SQLView. Switch to SQLView and copy/paste the SQL statement. Provide sample data.

    As I said, what you show looks correct if you want to retrieve records where field is null.
    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.

  5. #5
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    I see. Sorry... I will give it a try.

  6. #6
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    June7, very sorry for these novice questions. So, I think SELECT * FROM table WHERE RefType Is Null will simply put a Is Null in the criteria of the query. I know that, but what really need to happen, is I am trying to pull some values from a form, but if the value on the form field is Null, then, I want to query all the Nulls, otherwise, I want to query the value on that field.

    Field1 on the form: AAA or BBB

    In the Query, If it is not AAA or BBB, then show all the Nulls. Therefore,

    IIF(IsNull([Field1] = True, Is Null, Field1)

    Sorry for the confusion.

  7. #7
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,740
    If you want the argument to be the words "is Null", then

    IIF(IsNull([Field1] = True, "Is Null", Field1)

    If you want the argument to be null, then

    IIF(IsNull([Field1] = True,Null, Field1)


  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    You want conditional criteria based on what is in a control on form?

    Unfortunately, operators (= <> LIKE, etc) cannot be dynamic. Only way I can see to do in query what I think you want is to calculate substitute value for the nulls.

    WHERE Nz(fieldname,"zzz") = Nz(Forms!formname!controlname, "zzz")


    I really don't like dynamic parameterized queries. I prefer VBA to set filter criteria. Review http://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.

  9. #9
    perryc is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2019
    Posts
    122
    Ty all again!!

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

Similar Threads

  1. Replies: 4
    Last Post: 04-09-2019, 02:05 PM
  2. Replies: 4
    Last Post: 03-11-2017, 09:48 PM
  3. Replies: 7
    Last Post: 11-07-2016, 09:24 AM
  4. Replies: 1
    Last Post: 02-23-2012, 02:27 PM
  5. Finding the Max Date and Null Values if Null
    By SpdRacerX in forum Queries
    Replies: 1
    Last Post: 02-03-2012, 06:29 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