Syndicate content

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:

Parent.NewSelection

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

Private Sub NewSelection
    DoSomething
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.

Syndicate content

Diverse Realty

Diverse Realty Team

Want a New Home?
Want to Sell Your House?

Call Alex at
+1 (916)
220 6482

Alexis Wilke, Realtor
Salesperson
Lic. # 02024063

Cory Marcus, Broker
Lic. # 01079165

     

Terms of Site Index

Find the page/content you are looking for with our index.