?
Solved

Object Required Error

Posted on 2011-10-19
6
Medium Priority
?
252 Views
Last Modified: 2013-11-27
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

0
Comment
Question by:Cody Vance
6 Comments
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 1000 total points
ID: 36994722

which line is raising the error?

try this one


Private Sub Form_Load()
If Me.txtAddress1 & ""="" Then
    Me.lblAskAddress.Visible = True
Else
    Me.lblAskAddress.Visible = False
End If
End Sub
0
 
LVL 33

Assisted Solution

by:jppinto
jppinto earned 1000 total points
ID: 36994724
Try either like this:

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

or like this:

Private Sub Form_Load()
If IsNull(Me.txtAddress1.Value) Then
    Me.lblAskAddress.Visible = True
Else
    Me.lblAskAddress.Visible = False
End If
End Sub

(not sure what works...not able to test on this computer!)
0
 
LVL 5

Expert Comment

by:MikkelAStrojek
ID: 36994728
Have you tried changing Null to Nothing
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
LVL 10

Expert Comment

by:VTKegan
ID: 36994745
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

0
 

Author Closing Comment

by:Cody Vance
ID: 36994884
Both worked, thanks!
0
 
LVL 75
ID: 36994887
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
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Windows Explorer let you handle zip folders nearly as any other folder: Copy, move, change, and delete, etc. In VBA you can also handle normal files and folders, but zip folders takes a little more - and that you'll find here.
In a use case, a user needs to close an opened report by simply pressing the Escape (Esc) key. This can be done by adding macro code in Report_KeyPress or Report_KeyDown event.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question