Text box visibility

  • Thread starter Thread starter Harvey
  • Start date Start date
H

Harvey

Hello, can anybody help? Is it possible for a text box in
a report to be visible only if there is any data in it.
To clarify, I have text box in which I sometimes have put
in some notes/instructions. If, (which is the norm) I
don't have any notes/instructions, I am left with a
rectangular box on the report.

Thanks Harvey
 
Yes, there are a couple of ways. First, you can use the Can Shrink property
of the text box. If the data for the text box is Null, the textbox will
shrink to zero height. This will work as long as there is nothing else
horizontally in line with the textbox on the report (except for its own
attached label). If Can Shrink doesn't work for you, you can use code in the
Format event of the section the textbox is in to toggle its Visible
property.

If Nz(Me.txtMyTextbox, "") = "" Then
Me.txtMyTextbox.Visible = False
Else
Me.txtMyTextbox.Visible = True
End If

The above could be shortened to the following, if you wish.

Me.txtMyTextbox.Visible = Not (Nz(Me.txtMyTextbox, "") = "")
 
Works Fine. Thank you very much

Harvey
-----Original Message-----
Yes, there are a couple of ways. First, you can use the Can Shrink property
of the text box. If the data for the text box is Null, the textbox will
shrink to zero height. This will work as long as there is nothing else
horizontally in line with the textbox on the report (except for its own
attached label). If Can Shrink doesn't work for you, you can use code in the
Format event of the section the textbox is in to toggle its Visible
property.

If Nz(Me.txtMyTextbox, "") = "" Then
Me.txtMyTextbox.Visible = False
Else
Me.txtMyTextbox.Visible = True
End If

The above could be shortened to the following, if you wish.

Me.txtMyTextbox.Visible = Not (Nz(Me.txtMyTextbox, "") = "")

--
Wayne Morgan
MS Access MVP





.
 
Back
Top