Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28

    Query for Label where field is null


    Hi. I'm trying to create a query for labels. I want it to filter by Support Field contains X and Email Field is empty. I can't seem to type in the right thing for the email empty criteria. Please help. Thanks.

  2. #2
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    On the Criteria line for that field, just use:
    Code:
    Is Null

  3. #3
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    I am using Is Null in the email fields criteria, but when I run the query it's not bringing anything up.

    I need Support Field to contain X, so in the Criteria I have "X"
    AND
    I need the Email Field to be empty, so in the Criteria I have "IsNull"

    When query is run, nothing is showing

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    It is two words "Is Null", not "IsNull".

    If you are still having issues getting it to work, please switch your query to SQL View and copy and paste the SQL code here for us to analyze.

  5. #5
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    SELECT DONORS.ACCTID, DONORS.TITLE, DONORS.FNAME, DONORS.LNAME, DONORS.ADDR1, DONORS.CITY, DONORS.STATE, DONORS.ZIP, DONORS.COUNTRY, DONORS.SUPPORT1, DONORS.EMAIL1, DONORS.EMAIL2
    FROM DONORS
    WHERE (((DONORS.SUPPORT1)="X") AND ((DONORS.EMAIL1)="Is Null") AND ((DONORS.EMAIL2)="Is Null"))
    ORDER BY DONORS.ACCTID;

  6. #6
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    When you place "Is Null" between quotes in your criteria, it is looking for a literal text entry of "Is Null". If you want to check if the entries are actually Null, don't use the double quotes, i.e.
    Code:
    WHERE (((DONORS.SUPPORT1)="X") AND ((DONORS.EMAIL1) Is Null) AND ((DONORS.EMAIL2) Is Null))
    Note how if post #2 when I showed you what to enter in on the Criteria line, I did not use any double-quotes.

  7. #7
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    Took out the "", still does not show the data.


    SELECT DONORS.ACCTID, DONORS.TITLE, DONORS.FNAME, DONORS.LNAME, DONORS.ADDR1, DONORS.CITY, DONORS.STATE, DONORS.ZIP, DONORS.COUNTRY, DONORS.SUPPORT1, DONORS.EMAIL1, DONORS.EMAIL2
    FROM DONORS
    WHERE (((DONORS.SUPPORT1)="X") AND ((DONORS.EMAIL1) Is Null) AND ((DONORS.EMAIL2) Is Null))
    ORDER BY DONORS.ACCTID;

  8. #8
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I set up an example like yours, and the code worked for me.

    So that makes me question whether these EMAIL fields are really null/empty, or they contain something like a single space in them.

    Try running this code:
    Code:
    SELECT DONORS.ACCTID, DONORS.TITLE, DONORS.FNAME, DONORS.LNAME, DONORS.ADDR1, DONORS.CITY, DONORS.STATE, DONORS.ZIP, DONORS.COUNTRY, DONORS.SUPPORT1, DONORS.EMAIL1, DONORS.EMAIL2, 
    LEN(DONORS.SUPPORT1) as LenSUPPORT1, LEN(DONORS.EMAIL1) as LenEMAIL1, LEN(DONORS.EMAIL2) as LenEMAIL2
    FROM DONORS
    ORDER BY DONORS.ACCTID;
    And locate a record which you think should be captured by the code we are trying to come up, and let me know what values the three new calculated fields at the end are returning.

  9. #9
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    For empty email fields
    LenSUPPORT = 1
    LenEMAIL1 = 0
    LenEMAIL2 = this column is empty

    For non empty email fields
    LenSUPPORT = 1
    LenEMAIL1 = 30
    LenEMAIL2 = this column is empty

  10. #10
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    OK, it appears that there is some sort of unexpected difference between EMAIL1 and EMAIL2.
    Are the values coming from the same place?
    Are the fields set up exactly the same (what is their Data Types)?

    Let me know what this returns for empty email fields:
    Code:
    SELECT DONORS.ACCTID, DONORS.TITLE, DONORS.FNAME, DONORS.LNAME, DONORS.ADDR1, DONORS.CITY, DONORS.STATE, DONORS.ZIP, DONORS.COUNTRY, DONORS.SUPPORT1, DONORS.EMAIL1, DONORS.EMAIL2, 
    LEN(DONORS.SUPPORT1) as LenSUPPORT1, LEN(DONORS.EMAIL1 & "X") as LenEMAIL1, LEN(DONORS.EMAIL2 & "X") as LenEMAIL2
    FROM DONORS
    ORDER BY DONORS.ACCTID;

  11. #11
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    Empty email fields
    LenEMAIL1 = 1
    LenEMAIL2 = 1

    Note: All Email2 fields will be empty as no data has of yet been entered into them, but there may be in the future.

    Data is from the same Donors Table
    Data Type is Short Text

  12. #12
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    OK, this workaround should give you what you want:
    Code:
    SELECT DONORS.ACCTID, DONORS.TITLE, DONORS.FNAME, DONORS.LNAME, DONORS.ADDR1, DONORS.CITY, DONORS.STATE, DONORS.ZIP, DONORS.COUNTRY, DONORS.SUPPORT1, DONORS.EMAIL1, DONORS.EMAIL2
    FROM DONORS
    WHERE (((DONORS.SUPPORT1)="X") AND (LEN(DONORS.EMAIL1 & "X")=1) AND (LEN(DONORS.EMAIL2 & "X")=1)
    ORDER BY DONORS.ACCTID;

  13. #13
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    Alright, that seems to work! Thank you so much. Sorry it took so long.

  14. #14
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Glad we got it working out for you.

    Blanks/nulls/empty/spaces sometimes can be problematic to work with.
    Sometimes it likes "Is Null", other times "" will work. I am sure there is some rhyme or reason to it (if there, I cannot keep it straight!).
    By adding a single character to the value and checking for a length of 1, that takes care of both situations in one fellow swoop.

  15. #15
    cshipley83 is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Aug 2016
    Posts
    28
    It's so confusing, especially since I'm not an expert at this stuff.

    Sorry, but I just realized that I also need these labels to not pull up any addresses that are blank. How do I add that in to your SQL formula?

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Hide report label when text box is null/blank
    By crsport3 in forum Access
    Replies: 7
    Last Post: 10-30-2013, 07:14 AM
  2. Update query to set null value lookup field
    By alexjose in forum Access
    Replies: 1
    Last Post: 06-24-2013, 04:26 PM
  3. Replies: 5
    Last Post: 09-18-2012, 12:39 PM
  4. Query Help - Show field if another field is null
    By lukekonrad in forum Access
    Replies: 1
    Last Post: 03-05-2012, 04:02 PM
  5. Total Query(One field with Null value)
    By vidplaylist in forum Queries
    Replies: 1
    Last Post: 11-30-2011, 03:57 PM

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