Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Hide Label (2003)

    I have a label next to a corresponding text box. (i.e. Unit ###) Unit is the label and the ### is the number from my query. If the text box is blank, is it possible to hide my label? Thanks in advance.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Label (2003)

    Where are the text box and label?
    a) On a single form
    [img]/forums/images/smilies/cool.gif[/img] On a continuous form
    c) On a report

  3. #3
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide Label (2003)

    My apologies for the delay. The fields are on a report.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Label (2003)

    You can write code for the On Format property of the section (probably the Detail section) that contains the text box and label:

    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    Me.LabelName.Visible = Not IsNull(Me.TextBoxName)
    End Sub

    with the appropriate names substituted.

  5. #5
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide Label (2003)

    Hi Hans,

    I tried the code with no luck. I'm sure I'm doing something incorrectly. I've actually got the text box and label in a section titled "OwnerHeader". My label is named "Unit_Num" and the text box is named "Text47". Here is the code...

    Private Sub OwnerHeader_Format(Cancel As Integer, FormatCount As Integer)
    Me.Unit_Num.Visible = Not IsNull(Me.Text47)
    End Sub

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Label (2003)

    Perhaps the text box is not really blank. Try this variation:
    <code>
    Me.Unit_Num.Visible = Not (Trim(Nz(Me.Text47,"")) = "")
    </code>
    This should work if the text box contains an empty string "", or one or more spaces.

  7. #7
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide Label (2003)

    Thanks for the quick feedback. I gave that a shot with no success. I'm going to see if it has something to do with the section i have it in.

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Hide Label (2003)

    If you wish, you can post a stripped down copy of your database. See <post#=401925>post 401925</post#> for instructions.

  9. #9
    2 Star Lounger
    Join Date
    Mar 2002
    Posts
    164
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Hide Label (2003)

    Hans,

    I went back and modified my query to insert Null if the field is blank. The code worked perfectly after that. Thanks again!!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •