The Linux Page

MS-Access: Application-defined or object defined error

Today I got this weird error: Application-defined or object defined error.

Looking into it, I could not find the right answer.

The failing code was in a sub-form and when called it generated the error immediately. The code I wrote was:


And of course, in the parent I had the NewSelection function defined:

Private Sub NewSelection
End Sub

The DoSomething would update a button as required...

For real MS-Access pros, you may already have noticed what the problem was. What's really annoying is that the error we get is not capable of telling us what is really going on...

The Sub I defined there was marked as PRIVATE. That simple. Just change that keyword with Public and it works just fine.

The reasons for not being able to tell that the function should maybe be marked as public is that the name is hidden from external modules (including sub-forms.)

The annoying part is that the software was finding the function because if you call a function that is 100% not defined you instead get an error saying the function cannot be found. But somehow it is not capable of telling you, clearly, that the function is private.

SMS From Me Logo

SMS From Me

To automatically start one on one conversations with your online leads.