Unable to Hide control when the value is null

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • RajeshKesari

    Unable to Hide control when the value is null

    Pls help; I suppose following would be the right code to hide an empty control (TestMethod) but its not working; I checked by making a query- When I put a criteria IsNull the field is removed from the query results which means that the empty fields are actually "Null"; I tried using some existing values of the field test method- it works e.g when I substituted Null with "Slide Method" all entries containing "slide method" are removed/Hidden.

    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
    If Me.TestMethod = Null Then
    Me.TestMethod.Visible = False
    End If
    
    End Sub
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32661

    #2
    You're on the right track, but Null isn't a value as such so cannot be compared against. You should use the function IsNull() instead. This returns TRUE if the parameter passed is Null. Your code could read :
    Code:
    Private Sub Detail_Format(Cancel As Integer, FormatCount As Integer)
        Me.TestMethod.Visible = (Not IsNull(Me.TestMethod))
    End Sub
    This also handles the other point which you missed, which is to reset the control as visible for all other occasions ;-)

    Comment

    Working...