Report: Hide labels if text boxes are empty

MvP14

Registered User.
Local time
Today, 19:58
Joined
Apr 15, 2003
Messages
66
Hi,

I'm trying to hide labels on a report when text boxes are empty.

The labels and text boxes are in the details section.

I use:

Me.labelName.Visible = Not (IsNull(Me.txtName))
Me.labelStreet.Visible = Not (IsNull(Me.txtStreet))
...

I put the in the OnFormat of the Details section, however, the labels are not hidden when the textboxes are empty.

I also read a post that suggested putting the code in OnCurrent of the Report, however, that doesn't work either. It only works if and when I set focus on a record.

Does anyone how to fix this? I've been searching for a while, so any help is very much appreciated. Thanks in advance.
 
Thank you for the reply.

Since I'm not sure whether the label and text box are linked, and how to hide the text box, I first tried the second solution. It doesn't do the trick.

So, I'd like to know:
- how do I know for sure whether the label and text box are linked (the label appeared when I dragged the text box to the report, so I assume it is linked, even though I changed its text);
- how do I hide the text box? Currently, it is hidden when it is empty since I set CanShrink to Yes, but is that what you mean, or is there another way?

It's been eight years since I've worked with some VBA. Even back then I was at amateur level ...

Thank you for your reply.
 
So they are linked, the CanShrink is set to yes, the code is as mentioned above and it is in Private Sub Details_Format(Cancel As Integer, FormatCount As Integer), but still, the labels show when the text is empty.

I just found out though that they disappear in print preview, but not in what I would translate as "Report view" (I don't have an English version, it is next to design view and "division view"?), which is where I had been looking at all the time.

Maybe it's just not possible to remove them in "report view"?

I'm really sorry I wasted your time if that is the case, I should have noticed earlier.
 
Thank you. I 've tried that, but I get an error code 32521: "you cannot change the value of this property in the event OnPaint". (freely translated). Should I change anything?
 

Users who are viewing this thread

Back
Top Bottom