Results 1 to 8 of 8
  1. #1
    crsport3 is offline Novice
    Windows 7 32bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    3

    Hide report label when text box is null/blank

    I am attempting to use VBA code to make the label in my report hidden if the text box is blank. I am very new to coding, and am not sure how I would express this in code. I have been looking at a few examples of how to get this done, but it doesn't seem to work. If anyone can help me with the coding and where to insert the code. Attached is the image of the properties for my label and text box that I want hidden if text field is blank. I al just lost trying to figure this out.
    Click image for larger version. 

Name:	labels-text box properties.png 
Views:	17 
Size:	28.1 KB 
ID:	14223


  2. #2
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    put your code into the OnFormat event of the section that holds the text field.

    Hope this helps

  3. #3
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    Access MVP Allen Browne posted a simple answer in this thread: http://answers.microsoft.com/en-us/o...3-f26b88434cd2

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,822
    Is hiding controls really necessary? They still occupy space even if they can't be seen.
    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
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    It's a look and feel thing.

  6. #6
    crsport3 is offline Novice
    Windows 7 32bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    3
    The problem is I do not know the code to use. I tried using the link provided by Dal, but that didn't work either. It would still show the text when I changed it to a text box and changed to control source.

  7. #7
    crsport3 is offline Novice
    Windows 7 32bit Access 2010 64bit
    Join Date
    Oct 2013
    Posts
    3
    I found a forum answer that worked. I used the code
    If Paidbyrbt4 & "" = "" Then
    Label86.Visible = False
    Else
    Label86.Visible = True
    End If

    If I wanted to add a second and third if statement, would I enter it before the End If statement like I have below? Or would I just start its own after the End if?

    If Paidbyrbt4 & "" = "" Then
    Label86.Visible = False
    Else
    Label86.Visible = True
    If Paidbyrbt5 & "" = "" Then
    Label87.Visible = False
    Else
    Label87.Visible = True
    End If

  8. #8
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    If they are independent, then just do two different sets of IF THENs.

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

Similar Threads

  1. Replies: 5
    Last Post: 09-18-2012, 12:39 PM
  2. Replies: 1
    Last Post: 04-26-2012, 08:31 PM
  3. Hide Null Values in Report
    By rdr910 in forum Reports
    Replies: 10
    Last Post: 03-15-2012, 03:09 PM
  4. Importing text file with blank fields changes to null
    By Egoyret in forum Import/Export Data
    Replies: 9
    Last Post: 11-10-2011, 01:51 PM
  5. Replies: 3
    Last Post: 09-15-2010, 01:04 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