Show Hide Textbox/label

D

Donna

What's wrong with this code? Access 2007
I want the label to be invisible also if the value of the text box is null.


Private Sub Report_Load()
Dim strRpt As String

If Me.ReadingList.Value Is Null Then

Me.ReadingList.Visible = False
Else

Me.ReadingList.Visible = True

End If
 
D

Duane Hookom

I expect the issue is where you are running the code. Have you tried moving
the code to the section of the report containing the control?

Try this:
Me.ReadingList.Visible = Not IsNull(Me.ReadingList)
 
M

Marshall Barton

Donna said:
What's wrong with this code? Access 2007
I want the label to be invisible also if the value of the text box is null.


Private Sub Report_Load()
Dim strRpt As String

If Me.ReadingList.Value Is Null Then

Me.ReadingList.Visible = False
Else

Me.ReadingList.Visible = True

End If


Is Null is an SQL operator, it isn't available in VBA. Use
the IsNull function instead. This one line should do what
you want:

Me.ReadingList.Visible = Not IsNull(Me.ReadingList)
 

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