Show Hide Textbox/label

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
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)
 
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)
 
Back
Top