The kindness of strangers - hide text box

rgates

Registered User.
Local time
Today, 06:33
Joined
Mar 21, 2006
Messages
10
I did search to find the answer to this question, but each question was slightly different from mine.

I want to hide a text box in a report if the value is 0. I don't know enough code to know what mistakes I am making.

I tried this :
Me.[MyTextBox].Visible=Not IsNull.true

Please don't laugh. I'm going to start learning vb as soon as I get done with this project! I promise.
 
Look up 'conditional formatting' in the search feature of this forum.
 
Code:
Me.MyTextBox.Visible = IIf(Me.MyTextBox = "0", False, True)

Bobadopolis
 
Bobadopolis said:
Code:
Me.MyTextBox.Visible = IIf(Me.MyTextBox = "0", False, True)

Bobadopolis

Will that work if there is more than one row/textbox instance in the report?....
 
Yes it will - tried and tested!

It has to be an IIf though - regular Ifs do not work(!?)

You can abbreviate this even further:

Code:
Me.MyTextBox.Visible = Not (MyTextBox = "0" Or IsNull(MyTextBox))

Bobadopolis
 
I keep getting an error

Private Sub Report_Open(Cancel As Integer)
Me.[Units of Service 2 September].Visible = IIf(Me.[Units of Service 2 September] = "0", False, True)
End Sub

I get a compile error - method or data member not found and it highlights .Visible =
 
Put the code in the OnFormat Event of the Detail section...

Bobadopolis
 
Thank you, thank you, thank you!
Finally!
I used the IIf function, but I put it in the Control Source of a text box.
= IIf([Units of Service 2 September] =0, " ", [Units of Service 2 September])
One problem I was having was that you had true and false switched, so I got the opposite of what I was trying for.

I worked all day on this. But what a lesson! Thank you again!
Rhonda
 

Users who are viewing this thread

Back
Top Bottom