Make Label invisible if no info in text box (1 Viewer)

HappyApple

Registered User.
Local time
Today, 01:22
Joined
Jan 10, 2003
Messages
15
Hi everybody I wonder if you could help me?

I am reporting on certain charactistics and there are a lot of memo fields ... some of which are empty. The report is Columnar.

Is there a way to hide the label if the memo field is empty?

many thanks for any help you can give.

Michelle
 

ansentry

Access amateur
Local time
Today, 10:22
Joined
Jun 1, 2003
Messages
995
Open your report in design view, right click "Detail" select Properties and put the code (in bold) in the OnFormat. Change MyMemo to the name of your memo control.

Code:
Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)  

 [B]Me.MyMemo.Visible = Not IsNull(Me.MyMemo)[/B]

End Sub
 

HappyApple

Registered User.
Local time
Today, 01:22
Joined
Jan 10, 2003
Messages
15
that has worked a treat

thank you so very much for your help :)
 

ss6857

Registered User.
Local time
Yesterday, 19:22
Joined
Jul 12, 2011
Messages
38
Could someone explain this a little more please? I did the steps ansentry explained, however, I think I messing up what I put in place of 'Me' and 'MyMemo.' For example, if I had a report called "Apples" and I wanted to manipulate the "Price" label would I put
Apples.Price_Label.Visible = Not IsNull(Apples.Price)
 

ansentry

Access amateur
Local time
Today, 10:22
Joined
Jun 1, 2003
Messages
995
I think this will work for you;

Code:
Me.Price.Visible = Not IsNull(Me.Price)


Have a look at my attached sample.
 

Attachments

  • Non_Visible Labels.mdb
    192 KB · Views: 912

ss6857

Registered User.
Local time
Yesterday, 19:22
Joined
Jul 12, 2011
Messages
38
When I put "Me" Access says it can't find that object. And then I put a report name in it and it still can't find the object. I'm working with the latest version of Access if that helps.
 

ansentry

Access amateur
Local time
Today, 10:22
Joined
Jun 1, 2003
Messages
995
1. Does my sample work?

2. Why are you putting the report name in?

3.Is "Price" the name of the control in the report?

Post a copy of your database with just the report and applicable table(s) and I will have a look at it for you.
 

ss6857

Registered User.
Local time
Yesterday, 19:22
Joined
Jul 12, 2011
Messages
38
Your sample cleared a lot of things up. However I think I know what the problem is. The labels are located in the page header and the text is located in the detail. (to avoid the labels repeating) Also, the labels may still be visible because in my query, all the labels have data with them, but in my report I have a page break after certain criteria. Is there a way to determine if there is no information under the labels on one page those labels will not show but show on the pages where there is data on the page?
 

ss6857

Registered User.
Local time
Yesterday, 19:22
Joined
Jul 12, 2011
Messages
38
So far for my code I have:


Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Me.Level1_Label.Visible = (Me.Category_ID = 1)
Me.Level1.Visible = (Me.Category_ID = 1)
Me.Level2_Label.Visible = (Me.Category_ID = 1)
Me.Level2.Visible = (Me.Category_ID = 1)
Me.Level3_Label.Visible = (Me.Category_ID = 1)
Me.Level3.Visible = (Me.Category_ID = 1)
Me.SugFleetW_Label.Visible = (Me.Category_ID = 1)
Me.SugFleetW.Visible = (Me.Category_ID = 1)
End Sub

Category_ID is a group and is what I use to determine page breaks. This code works until I add more the one Category_ID number:

Me.SugFleetWLabel.Visible = (Me.Category_ID = 2)
Me.SugFleetW.Visible = (Me.Category_ID = 2)

The minute I add that SugFleetW also is visible for Category 2, it disappears for Category 1. Is there a way I can say it should be visible on multiple categories?
 
Last edited:

ss6857

Registered User.
Local time
Yesterday, 19:22
Joined
Jul 12, 2011
Messages
38
Nevermind. I figured it out. For anybody's future reference:

Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
Me.Level1.Visible = (Me.Category_ID = 1)
Me.Level2.Visible = (Me.Category_ID = 1)
Me.Level3.Visible = (Me.Category_ID = 1)
Me.SugFleetW.Visible = ((Me.Category_ID = 1) Or (Me.Category_ID = 2))
Me.Price.Visible = ((Me.Category_ID = 2) Or (Me.Category_ID = 6) Or (Me.Category_ID = 7) Or (Me.Category_ID = 8) Or (Me.Category_ID = 9) Or (Me.Category_ID = 13) Or (Me.Category_ID = 45))
Me.SugFleet.Visible = ((Me.Category_ID = 8) Or (Me.Category_ID = 13) Or (Me.Category_ID = 44) Or (Me.Category_ID = 45))
End Sub

Private Sub PageHeaderSection_Format(Cancel As Integer, FormatCount As Integer)
Me.Level1_Label.Visible = (Me.Category_ID = 1)
Me.Level2_Label.Visible = (Me.Category_ID = 1)
Me.Level3_Label.Visible = (Me.Category_ID = 1)
Me.SugFleetW_Label.Visible = ((Me.Category_ID = 1) Or (Me.Category_ID = 2))
Me.Price_Label.Visible = ((Me.Category_ID = 2) Or (Me.Category_ID = 6) Or (Me.Category_ID = 7) Or (Me.Category_ID = 8) Or (Me.Category_ID = 9) Or (Me.Category_ID = 13) Or (Me.Category_ID = 45))
Me.SugFleet_Label.Visible = ((Me.Category_ID = 8) Or (Me.Category_ID = 13) Or (Me.Category_ID = 44) Or (Me.Category_ID = 45))
End Sub
 

Users who are viewing this thread

Top Bottom