Question

I have a subform embedded in a main form. I have the following code for the onClick event of one field in my subform.

Private Sub my_field_Click()
If Not Me!my_field.Value Is Null Then

    'my code here...

End If
End Sub

I want to update a text box with a click on the field, but I got an error when I click the field before the subform is not fully initiated (by setting the field's data source). So I wrote the above code to check if there is any value now in the field. However, I got the run-time error 424: Object required when running this code. Strangely, when I inspect the value of Me!my_field.Value in the debug window at run time, it does give NULL value.

Any idea what went wrong here? What else should I do to do this checking?

I am running this in Access 2000.

Was it helpful?

Solution

Use the IsNull() function in VBA code.

If Not IsNull(Me!my_field.Value) Then
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top