0

Working in MSAccess. I'm trying to toggle the visibility of a button based on the value of a text box. The form was created off of a query. I've made sure the value in the tbl_Manufacturer.Website is Null. But the code keeps validating as false and drops into the next set of code. What did I miss?

Private Sub Form_Load()

    If ([Forms]![frm_Asset]![tbl_Manufacturer.WebSite]) = Null Then
            
        btn_Hyperlink.Visible = False
    
    Else
        
        btn_Hyperlink.Caption = [Forms]![frm_Asset]![tbl_Manufacturer.WebSite]
        btn_Hyperlink.Visible = True
    
    End If

End Sub

-Jeff

Brian M Stafford
  • 7,875
  • 2
  • 17
  • 24
JMJ
  • 35
  • 6

3 Answers3

3

Nothing is ever equal to Null, since Null is a missing value. Something = Null is always going to return Null, which evaluates to false.

If you want to test if a field is null, use the IsNull function:

If IsNull([Forms]![frm_Asset]![tbl_Manufacturer.WebSite]) Then
Erik A
  • 30,261
  • 11
  • 41
  • 58
0

Try using IsNull instead:

If (IsNull([Forms]![frm_Asset]![tbl_Manufactuer.Website]) Then ......

Testing if a string is null

Mr Rob
  • 49
  • 5
-1

In addition to the IsNull option presented by other answers, you can simply compare to an empty string, since this is a text box:

If ([Forms]![frm_Asset]![tbl_Manufacturer.WebSite]) Is Not "" Then