Results 1 to 6 of 6
  1. #1
    wwconslt is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    9

    Display Null Value in Field B if Field A is Null

    Hello Everyone,



    I thought this query expression would be simple but am having problems.

    I have a field called Parent 1 Email. If the [Parent 1 Email] field is null, then I'd like the [EmailType] field to also be Null, else populate with "EH".

    I've tried this in design view of the query:

    PARENT_EMAILTYPE: IIf([Parent 1 Email] Is Not Null,"EH",Null)

    But what's happening is it's populating the email type column in the query with "EH" even if there is no email.

    Any help is appreciated.

  2. #2
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    IIf(Not IsNull([Parent 1 Email]),"EH")

  3. #3
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Are you sure that Parent 1 Email is null? It may be blank.

    IIf(Not IsNull([Parent 1 Email]) And [Parent 1 Email]<>"","EH")

  4. #4
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    I have a field called Parent 1 Email. If the [Parent 1 Email] field is null, then I'd like the [EmailType] field to also be Null, else populate with "EH".
    This [EmailType] field you are talking about is just a calculated field in a query, right? Not a field in a table?
    If you want to update an actual table field, you would need to use an Update Query to do so.

    I tested out this expression in a query:
    Code:
    PARENT_EMAILTYPE: IIf([Parent 1 Email] Is Not Null,"EH",Null)
    and it seemed to work correctly for me. It only populated "EH" for records where [Parent 1 Email] is not null.
    If it is populating all of them, then that field is probably not null. You can confirm that pretty easily with an expression like this:
    Code:
    CHECK: Len([Parent 1 Email])
    If it returns any number, then the [Parent 1 Email] field is not null.

  5. #5
    wwconslt is offline Novice
    Windows 10 Access 2016
    Join Date
    Apr 2017
    Posts
    9
    Thank you everyone for your responses!

    aytee111, you were exactly right. The fields must be blank not null so your solution worked! I thought Null and Blank were the same thing. Could you please tell me the difference?

    Thanks Joe for the Len tip to check for null values.

  6. #6
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Not sure the exact technical reasons, it is how Access stores the value.

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

Similar Threads

  1. Replies: 7
    Last Post: 11-07-2016, 09:24 AM
  2. Replies: 3
    Last Post: 11-13-2013, 08:56 AM
  3. Replies: 3
    Last Post: 09-12-2013, 02:18 PM
  4. Display custom error if field is null or zero
    By steve87bg in forum Access
    Replies: 1
    Last Post: 01-14-2013, 02:33 AM
  5. If/Then Null based on Null Value of Another Field
    By vbpeterson in forum Queries
    Replies: 11
    Last Post: 06-05-2012, 05:00 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