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

3 Answers 3

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
Sign up to request clarification or add additional context in comments.

1 Comment

ISNULL! Thank you Erik, completely forgot that!
0

Try using IsNull instead:

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

Testing if a string is null

Comments

-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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.