Link to home
Start Free TrialLog in
Avatar of Cody Vance
Cody VanceFlag for United States of America

asked on

Object Required Error

Hi Experts,

Can someone tell me why I am getting an Object Required Error on this??  It seems like a simple SUB to me, but apparently I am missing something simple...

Cody-
Private Sub Form_Load()
If Me.txtAddress1.Value Is Null Then
    Me.lblAskAddress.Visible = True
Else
    Me.lblAskAddress.Visible = False
End If
End Sub

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Have you tried changing Null to Nothing
Change to:
Private Sub Form_Load()
If IsNull(Me.txtAddress1.Value) Then
    Me.lblAskAddress.Visible = True
Else
    Me.lblAskAddress.Visible = False
End If
End Sub

Open in new window

Avatar of Cody Vance

ASKER

Both worked, thanks!
Nothing only applies to Object variables, which is not the case here.
Try this

Private Sub Form_Load()
If Nz(Me.txtAddress1, "") ="" Then
    Me.lblAskAddress.Visible = True
Else
    Me.lblAskAddress.Visible = False
End If
End Sub