Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to hide labels/textboxes whenever not used

Status
Not open for further replies.

dabowles

MIS
Jun 26, 2001
64
US
Hi,
I am trying to hide some labels whenever the fields are not being used. I go into the report properties and go to the events tab, then go to Activate and I put in the following code:

If [ReasonforAddendum] = Null Then ReasonforAddendum.Visible = False
If [ReasonforAddendum] <> Null Then ReasonforAddendum.Visible = True
If [ReasonforAddendum] = Null Then ReasonLabel.Visible = False
If [ReasonforAddendum] <> Null Then ReasonLabel.Visible = True

It seems to take it just fine but it doesn't take the labels off the screen. If I try to put it in the &quot;On Open&quot; event, it gives me an error and says that the fields do not exist. What am I doing wrong, and how can I correct it?

Thanks,
Dave
 
When I'm trying to hide labels, rather than use labels I make another text box next to the field to be labeled and place an iif() statement that checks that there is data to label. Then you can use the canshrink property to eliminate wasted space (something you can't do with labels). It's much easier to manage and doesn't place any extra overhead on the report as the VBA does. Place the following in the ControlSource of your &quot;label&quot;:

=IIf([MyField]=&quot;&quot;,&quot;Hey I'm A Label:&quot;,&quot;&quot;)

Sometimes you need to use IsNull

=IIf(IsNull([MyField])=True,&quot;Hey I'm A Label:&quot;,&quot;&quot;) Joe Miller
joe.miller@flotech.net
 
I can understand how to hide the label, however, how can you do a function on a field that does not exists in the table anymore. I am having this same problem.
 
The field still exists in the table, it's just blank. That's what the function checks for. I don't understand the problem you're having... Joe Miller
joe.miller@flotech.net
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top