Hide a label

N

nirie1

I have tried several ways to hide the label in a report when the
attached field is empty. I tried changing the field to a textbox and
putting in =llf([Noncompliant Materials] Is Null,Null,"Noncompliant
BOM")

I get error.

I dont have any idea how to put code into a report. I want the label to
show when the attached field has text. I turned on grow and shrink but
of course that doesnt affect the label just the field. I saw several
posts already with this topic which is how I got the above but it
doesnt seem to work for me.

NonCompliant Materials is the name of my field. I want the label to
sahave an abbreviation what the field is so it can fit better on the
report. Thanks for any help!
 
F

fredg

I have tried several ways to hide the label in a report when the
attached field is empty. I tried changing the field to a textbox and
putting in =llf([Noncompliant Materials] Is Null,Null,"Noncompliant
BOM")

I get error.

I dont have any idea how to put code into a report. I want the label to
show when the attached field has text. I turned on grow and shrink but
of course that doesnt affect the label just the field. I saw several
posts already with this topic which is how I got the above but it
doesnt seem to work for me.

NonCompliant Materials is the name of my field. I want the label to
sahave an abbreviation what the field is so it can fit better on the
report. Thanks for any help!

Use an unbound text control as the label (not a Label control):

=llf(IsNull([Noncompliant Materials]), "" ,"Noncompliant BOM")

should work.

You can also place the following code in the Detail Format event if
you wish to use the existing label:

Me![LabelName].Visible = Not IsNull([NonCompliant Materials])
 
J

Jeff Boyce

When I have a label bound to a control that has Grow/Shrink turned on, if
the control has no data (null, not ""), then both the control and its label
"shrink".

Is there a chance that you added a "naked" control (no label), then added an
"orphan" label control (belongs to nothing), but never told the label
control that it belonged to the text (or whatever) control?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
N

Naeem Azizian

you need to put a code in the onformat event of your report:

If IsNull(Me.[Noncompliant Materials]) = True Then
Me.[Noncompliant Materials].Visible = False
Me.[lable Noncompliant Materials].Caption = ""
Me.[lable Noncompliant Materials].Visible = False
Else
Me.[Noncompliant Materials].Visible = True
Me.[Noncompliant Materials] = Me.[Noncompliant Materials]
Me.[lable Noncompliant Materials].Caption = "Non Compliant
Materials"
Me.[lable Noncompliant Materials].Visible = True
End If

hope this helps

Jeff said:
When I have a label bound to a control that has Grow/Shrink turned on, if
the control has no data (null, not ""), then both the control and its label
"shrink".

Is there a chance that you added a "naked" control (no label), then added an
"orphan" label control (belongs to nothing), but never told the label
control that it belonged to the text (or whatever) control?

Regards

Jeff Boyce
Microsoft Office/Access MVP


nirie1 said:
I have tried several ways to hide the label in a report when the
attached field is empty. I tried changing the field to a textbox and
putting in =llf([Noncompliant Materials] Is Null,Null,"Noncompliant
BOM")

I get error.

I dont have any idea how to put code into a report. I want the label to
show when the attached field has text. I turned on grow and shrink but
of course that doesnt affect the label just the field. I saw several
posts already with this topic which is how I got the above but it
doesnt seem to work for me.

NonCompliant Materials is the name of my field. I want the label to
sahave an abbreviation what the field is so it can fit better on the
report. Thanks for any help!
 
N

nirie1

I went to view and clicked on Code then put in just what you wrote in
the window. The window had general on the left and declartions on the
right. I'm not even sure if I was in the right place



I got an error message.

Naeem said:
you need to put a code in the onformat event of your report:

If IsNull(Me.[Noncompliant Materials]) = True Then
Me.[Noncompliant Materials].Visible = False
Me.[lable Noncompliant Materials].Caption = ""
Me.[lable Noncompliant Materials].Visible = False
Else
Me.[Noncompliant Materials].Visible = True
Me.[Noncompliant Materials] = Me.[Noncompliant Materials]
Me.[lable Noncompliant Materials].Caption = "Non Compliant
Materials"
Me.[lable Noncompliant Materials].Visible = True
End If

hope this helps

Jeff said:
When I have a label bound to a control that has Grow/Shrink turned on, if
the control has no data (null, not ""), then both the control and its label
"shrink".

Is there a chance that you added a "naked" control (no label), then added an
"orphan" label control (belongs to nothing), but never told the label
control that it belonged to the text (or whatever) control?

Regards

Jeff Boyce
Microsoft Office/Access MVP


nirie1 said:
I have tried several ways to hide the label in a report when the
attached field is empty. I tried changing the field to a textbox and
putting in =llf([Noncompliant Materials] Is Null,Null,"Noncompliant
BOM")

I get error.

I dont have any idea how to put code into a report. I want the label to
show when the attached field has text. I turned on grow and shrink but
of course that doesnt affect the label just the field. I saw several
posts already with this topic which is how I got the above but it
doesnt seem to work for me.

NonCompliant Materials is the name of my field. I want the label to
sahave an abbreviation what the field is so it can fit better on the
report. Thanks for any help!
 
N

Naeem Azizian

Here is what you have to do:
Go to the report's Design View
Double click on the details area of the report to open Details
properties page. (you can also choose Details1 from Objects drop down
list from the menu and then click on the properties tab.)
in the properties tab you have a tab named 'Event' click on that.
There you must see On Format
click in the text box and then click on the ... next to it.
Choose Code Builder from the window that appears.
Here you must put that code.

notice that you may need to modify the code in order to make sure all
the control names are typed correctly.

hope this helps,
I went to view and clicked on Code then put in just what you wrote in
the window. The window had general on the left and declartions on the
right. I'm not even sure if I was in the right place



I got an error message.

Naeem said:
you need to put a code in the onformat event of your report:

If IsNull(Me.[Noncompliant Materials]) = True Then
Me.[Noncompliant Materials].Visible = False
Me.[lable Noncompliant Materials].Caption = ""
Me.[lable Noncompliant Materials].Visible = False
Else
Me.[Noncompliant Materials].Visible = True
Me.[Noncompliant Materials] = Me.[Noncompliant Materials]
Me.[lable Noncompliant Materials].Caption = "Non Compliant
Materials"
Me.[lable Noncompliant Materials].Visible = True
End If

hope this helps

Jeff said:
When I have a label bound to a control that has Grow/Shrink turned on, if
the control has no data (null, not ""), then both the control and its label
"shrink".

Is there a chance that you added a "naked" control (no label), then added an
"orphan" label control (belongs to nothing), but never told the label
control that it belonged to the text (or whatever) control?

Regards

Jeff Boyce
Microsoft Office/Access MVP


I have tried several ways to hide the label in a report when the
attached field is empty. I tried changing the field to a textbox and
putting in =llf([Noncompliant Materials] Is Null,Null,"Noncompliant
BOM")

I get error.

I dont have any idea how to put code into a report. I want the label to
show when the attached field has text. I turned on grow and shrink but
of course that doesnt affect the label just the field. I saw several
posts already with this topic which is how I got the above but it
doesnt seem to work for me.

NonCompliant Materials is the name of my field. I want the label to
sahave an abbreviation what the field is so it can fit better on the
report. Thanks for any help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top