hiding label when no data

M

magick

i am trying to hide the label in a header when the field is blank, and based
on other discussions used the following code, but it is not working.

Private Sub GroupHeader1_Print(Cancel As Integer, PrintCount As Integer)
Me.lblSubclass.Visible = Not IsNull(Me.SUBCLASS_CODE)

End Sub

i believe the field is not null, but just blank, so tried the following code
(didn't work either)

Private Sub GroupHeader1_Print(Cancel As Integer, PrintCount As Integer)
If Me.SUBCLASS_CODE = "" Then
Me.lblSubclass.Visible = False

End If

End Sub

what dumb mistake am i making? thx
 
O

Ofer Cohen

The code should work, but to cover most cases try

Me.lblSubclass.Visible = Not (trim(Me.SUBCLASS_CODE) & "" ="")
 
A

Associates

Hi,

I have a similar problem as magick and tried the code given by Ofer Cohen.
It works. However, if i may ask whether it's possible to shrink the space of
the label. When it's not visible, it still takes up the space hence, there is
a gap in between. I have gone into Detail's properties and select "Yes" to
can shrink. The report still shows the gap in there.

Thank you in advance
 
M

Marshall Barton

Associates said:
I have a similar problem as magick and tried the code given by Ofer Cohen.
It works. However, if i may ask whether it's possible to shrink the space of
the label. When it's not visible, it still takes up the space hence, there is
a gap in between. I have gone into Detail's properties and select "Yes" to
can shrink. The report still shows the gap in there.


An invible text box (and its attached label) will shrink if
the text box's CanShrink property is set to Yes.

If there are no other unshrunk controls in the same
"horizontal band" AND the section's CanShrink property is
also set to Yes, then the horizontal band will shrink,
allowing any controls below the band to "move up".
 
A

Associates

Hi Marshall,

I tried it but it did not work. In the report, there are 5 controls of
text-boxes. Each have their own attached labels. They are all in the details
section of the report. I have gone into the details's properties and set the
"can shrink" to yes. I have also set "can shrink" for all the text-boxes to
yes except for the labels. For labels, could not find the option "can shrink"
in their properties.

Then, in the VB editor, i have the following code
Private Sub Detail_Print(Cancel As Integer, PrintCount As Integer)
Me.Label2.Visible = Not (Trim(Me.CompanySector) & "" = "")
End Sub

After running the report, it still shows gap when there is no data in the
company sector.

Thank you in advance
 
M

Marshall Barton

Labels can't shrink so, by itself, that won't do any good.
As I tried to say before the key concept is the "horizontal
band" containing the labels.

So, at this point I have to wonder if your labels are in a
different area of the section. For example, if the labels
are above the data controls, the data controls might shrink
without the label's shrinking, even if they are invisible.

Before speculating further, I need more specific details
about how all these controls are arranged in the report
section and if each label is attached to a text box (or
other data control).
 

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