Results 1 to 4 of 4
  1. #1
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85

    Label Visibility

    On my report, I have labels bound to their corresponding fields.
    If a field is blank, I want that label to not be visible.
    This is the code I am using, Not sure what is wrong with it.



    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    
    If IsNull(Me.Acc2) Then
    Me.Labelacc2.Visible = False
    End If
    
    
    If IsNull(Me.Acc3) Then
    Me.Labelacc3.Visible = False
    End If
    
    End Sub

  2. #2
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    First, you can't bind labels to data, so I'm not sure what you mean by that. You can link/attach them to controls though. For reports and continuous forms, if any record in a field/control does not meet the condition you specify, the effect is not applied to any of the controls in that field. Acc3 exists in each record whether or not it has data, and Access does not distinguish between the first row and the nth row. In your case, as long as even one is not Null, basically it (all of them) are all not Null. Note: I am not saying that conditional formatting cannot cause some to be colored differently than others. That is a different situation.
    Last edited by Micron; 05-02-2016 at 03:07 PM. Reason: grammar
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    joecamel9166 is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2016
    Posts
    85
    I figured it out.
    I put
    Code:
    ="[  ]" & Space$(5) & [Acc1]
    into an unbound textbox and used
    Code:
    If Acc1 = "" Then
    TextACC1.Visible = False
    End If
    in the code.

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    simpler code would be

    TextACC1.Visible=Acc1 <> ""

    or without your manipulation

    TextACC1.Visible=nz(Acc1,"") <> ""

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

Similar Threads

  1. Replies: 1
    Last Post: 04-25-2014, 11:41 AM
  2. Field Visibility
    By cbrsix in forum Programming
    Replies: 3
    Last Post: 06-27-2012, 03:52 PM
  3. subform visibility
    By nichmeg in forum Forms
    Replies: 9
    Last Post: 11-04-2011, 12:22 PM
  4. Visibility of other controls
    By jlclark4 in forum Forms
    Replies: 7
    Last Post: 12-15-2010, 12:34 PM
  5. Replies: 0
    Last Post: 11-24-2009, 03:23 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