totn Access

MS Access 2003: Run-time error 424 (Object Required)

This MSAccess tutorial explains how to fix the Run-time error '424': Object Required error in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, I'm using VBA code to set a value on another form and I keep getting a "Run-time error '424': Object Required" error. I can't seem to figure out why it won't work. The object that I'm referencing is valid and it should work. What am I doing wrong?

Microsoft Access

Answer: The problem isn't your code, it's that the Visual Basic editor does not recognize your form. In fact, the Visual Basic editor will not recognize your form until you've invoked the Code Builder (for your form or any object on your form) at least once.

Let's look at an example. In our database, we've created two forms - one called form1 and another called form2. We've invoked the Code Builder on form2.

When we take a look at the Visual Basic editor, we can see that form2 exists, but we can't see form1.

Microsoft Access

To fix this problem, we'll open form1 in design view. Next, display the properties for the Form object. Click on the button (with the three dots) on the "On Open" event for the form.

Microsoft Access

When the Choose Builder window appears, select Code Builder and click on the OK button.

Microsoft Access

Now when you return to the Visual Basic editor, form1 would appear in the list.

Microsoft Access

You can actually fix this error by invoking the Code Builder on any event in the form (or any one of the objects on the form). We've just chosen the form's "On Open" event for demonstration purposes.

Now when you run your VBA code, the "Object required" error should no longer appear.