Invisible Text Box

Kevin Field

Registered User.
Local time
Today, 12:56
Joined
May 26, 2010
Messages
35
Is it possible to set a text box on a report to only appear if another text box is not null?

I have a hunch that this is something to do with setvalue or similar in a macro? or even in the basic query the report is based on.

Any ideas?

Thanks!
 
On the SECTION where the control is placed, use this code in the ON FORMAT event of that section:

txtBoxToHide.visible = Not IsNull(txtBoxToTest.value)
 
I have used that code and replaced it with the names of the 'labels' which i need to make invisible. Sorry for the confusion in my topic post. I currently have this:

Label30.Visible = Not IsNull(Text21.Value)

Does this look right to you? Label30 needs to dissapear if Text21 is null.

Also, how do i add a second label to the above. I have two labels on the sub report which need to be blank if text21 is null.

Thanks!
 
Yes, that's correct. If it's null it would return TRUE but that would make the Visible property True, which is why you need to negate it to FALSE using Not.

Instead of using text21.value you can refer to the field instead.

Use the same code for the other label. It's either you set the visible property of the label or you set the caption to "".
 
Apologies for this but it still dosent seem to work.

Here is the Visual Basic code i have on the detail sections ON FORMAT.


Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)

Label30.Visible = Not IsNull(Text21.Value)
Label31.Visible = Not IsNull(Text21.Value)

End Sub

Any ideas?
 
Refer to the field instead of the control.

The only reason why it wouldn't work is because your field is returning a zero-length string instead of Null. If you want to test for both cases then use Len.

Label30.Visible = Len([Field] & "")
 

Users who are viewing this thread

Back
Top Bottom