Results 1 to 6 of 6
  1. #1
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13

    Hide Textbox Expression When Field Contents Have Null Values

    I would like to hide textbox expression when fields contained within textbox are null. The textbox expression is ="Team Member of" & " " & [Department] & ", " & [Office]

    This expression is fed by the fields, Department and Office. When there is no data for the fields, the textbox displays Team Member of ,. Is there a code that will hide 'Team Member of ,' when there is no data for the fields? If there is no information for the Department field there is no information for the Office field.

  2. #2
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows XP Access 2003
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    Untested but this may work:
    =IIF(Nz([Department],"") = "", "", "Team Member of" & " " & [Department] & ", " & [Office])
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  3. #3
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    Thanks so much, Bob. Code worked. If you have the time, can you briefly explain the logic behind this particular code string? Thanks again.

  4. #4
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    The IIf() function is a modification of the If...Then...Else construct, allowing it to be used in situations, such as this one, where a single line is needed.

    The syntax for IIF() is

    IIf(expr, truepart, falsepart)

    exp...Expression to be evaluated

    truepart...If the expression evaluate to True, do this.

    falsepart...If the expression evaluate to False do this.

    In this case, that would be

    =IIF(Nz([Department],"") = "", "", "Team Member of" & " " & [Department] & ", " & [Office])


    The expression bit

    Nz([Department],"") = ""

    evaluates whether or not [Department] is Null or contains a Zero-Length String. If either of these conditions is True, Nz() returns a Zero-Length String, otherwise it returns the Value in [Department].

    If the Expression evaluates to True, i.e. the [Department] Field is empty, the target Control is populated with a Zero-Length String.

    If the Expression evaluates to False, i.e. the [Department] Field is populated, the target Control is populated using your formatting,

    "Team Member of" & " " & [Department] & ", " & [Office]

    Does this help?

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  5. #5
    ANTHROPOIDLUVA is offline Novice
    Windows Vista Access 2007
    Join Date
    May 2012
    Posts
    13
    Excellent tutorial. I totally get this. Thanks for taking the time to teach me how to fish.

  6. #6
    Missinglinq's Avatar
    Missinglinq is online now VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Glad we could help!

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

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

Similar Threads

  1. Replies: 7
    Last Post: 07-02-2013, 12:02 PM
  2. Hide Null Values in Report
    By rdr910 in forum Reports
    Replies: 10
    Last Post: 03-15-2012, 03:09 PM
  3. Hide Null field Line
    By brobb56 in forum Access
    Replies: 1
    Last Post: 09-26-2011, 11:02 AM
  4. Hide Fields With Null Values
    By jay in forum Reports
    Replies: 6
    Last Post: 09-22-2011, 07:23 AM
  5. Replies: 0
    Last Post: 03-29-2011, 04:11 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