Results 1 to 6 of 6
  1. #1
    Shales is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2016
    Posts
    6

    Adding a "not is null" to my query

    Hi Everyone,

    Looking for some help. Here is part of my current query;



    +IIf(Format([DOB],"dd/mm/yyyy")=Format([DateOfBirth],"dd/mm/yyyy"),1,0)

    This is just part of my Expression Builder. What I am trying to do is count various matches in my data. It works, except for it will match records where both DOB fields are nulls. How can I ignore a match if they are NULL?

    Thanks
    Gavin

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,549
    In the query, filter out the nulls.

  3. #3
    Shales is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2016
    Posts
    6
    I don't think that will work for what I am trying to do. By filtering out will remove the lines completely and I need them in still because they might match on other criteria. I just need NULLs to be ignored in the count.

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Try using the NZ function to assign the NULLS a value, and choose different values for each one, i.e.
    Code:
    +IIf(Format(NZ([DOB],1),"dd/mm/yyyy")=Format(NZ([DateOfBirth],2),"dd/mm/yyyy"),1,0)

  5. #5
    Shales is offline Novice
    Windows 10 Access 2013 64bit
    Join Date
    Apr 2016
    Posts
    6
    Quote Originally Posted by JoeM View Post
    Try using the NZ function to assign the NULLS a value, and choose different values for each one, i.e.
    Code:
    +IIf(Format(NZ([DOB],1),"dd/mm/yyyy")=Format(NZ([DateOfBirth],2),"dd/mm/yyyy"),1,0)
    Perfect!, Thank you very much Joe.

  6. #6
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    You are welcome!

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

Similar Threads

  1. Replies: 1
    Last Post: 09-07-2015, 08:00 AM
  2. Replies: 4
    Last Post: 01-22-2015, 10:30 AM
  3. Adding "Open" column to Query Result
    By premis in forum Queries
    Replies: 12
    Last Post: 05-30-2012, 03:47 PM
  4. Passing criteria "NULL" or "IS NOT NULL" to a query
    By SgtSaunders69 in forum Forms
    Replies: 1
    Last Post: 12-24-2011, 02:22 AM
  5. Update query from form "invalid use of null"
    By Lady_Jane in forum Programming
    Replies: 4
    Last Post: 08-16-2011, 01:37 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