Don't Show Labels & Textboxes If "No"

M

Mark Jerde

MS Access 2003. Googling not successful.

I thought I did this several years ago but I don't recall how to do it and
I'm not figuring it out...

If a yes/no field is Yes I want to display three labels and textboxes. If
the yes/no field is No I don't want to display them, in effect shrinking
that part of the report. What do I need to do?

Thanks.

-- Mark
 
M

Marshall Barton

Mark said:
MS Access 2003. Googling not successful.

I thought I did this several years ago but I don't recall how to do it and
I'm not figuring it out...

If a yes/no field is Yes I want to display three labels and textboxes. If
the yes/no field is No I don't want to display them, in effect shrinking
that part of the report. What do I need to do?


Put the code in the Format event procedure of the section
containing the text boxes and labels:

Me.textbox1.Visible = (Me.yesnofield = True)
Me.textbox2.Visible = (Me.yesnofield = True)
Me.textbox3.Visible = (Me.yesnofield = True)

That assumes that the labels are attached to the text boxes.
If the labels are independent of the text boxes then you
will need to explicitly make them visible/invisible as well.

Make sure both the section and the text box's CanShrink
property is set to Yes.
 
M

Mark Jerde

Marsh -- Thanks! The report looks a lot better now.

I also had to set the visibility of the labels even though they are bound to
the textboxes.

-- Mark
 
M

Marshall Barton

An "attached" label will automatically appear/disappear when
it's parent control becomes visible/invisible. if that
wasn't what you were seeing, then the labels are not
attached to the text boxes. (It's easy to see if the label
is attached by dragging either one and noting that the other
one moves along with it.)

One thing to note is that a lable can not shrink. This
means that it's very important that the invisible label be
in the same horizontal "band" as a text box that shirnks.
 

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