Object Invalid Or No Longer Set - Error (1 Viewer)

odin1701

Registered User.
Local time
Yesterday, 21:50
Joined
Dec 6, 2006
Messages
526
I have a few people getting this error in my database. Happens when they try to save a record and then get a new one.

I have searched on Google and not found anything that seems to be related to my problem. I'm just curious how to get around this error. I don't mind if it pops up, but I want the users to be able to continue working after the error. It seems to save the record just fine, but when it tries to pull a new one that is the problem. It's just using a form.requery method for getting another record and the forms datasource is set to a SQL query.
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:50
Joined
Jul 2, 2005
Messages
13,826
That error could be the result of an unhandled error.
 

odin1701

Registered User.
Local time
Yesterday, 21:50
Joined
Dec 6, 2006
Messages
526
I have error handling in it, and it pops up my own dialog box when the error happens which I have in it do On Error.
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:50
Joined
Jul 2, 2005
Messages
13,826
The error you are getting is probably *after* you have already had an unhandled error. By the time you get that error it is already too late. Do you have good error handling throughout your application? Are you set to break on unhandled errors? Do you turn off error messages anywhere in your system (not recommended)?
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:50
Joined
Sep 12, 2006
Messages
14,630
i have found that just using

currentdb.something or other can cause problems for some reason

I now ALWAYS do

dim dbs as database
set dbs = currentdb


and then

dbs.something or other


----------
and I never get the out of scope error
 

RuralGuy

AWF VIP
Local time
Yesterday, 21:50
Joined
Jul 2, 2005
Messages
13,826
Dave probably hit the nail on the head.
 

LPurvis

AWF VIP
Local time
Today, 04:50
Joined
Jun 16, 2008
Messages
1,269
It is rather "pin the tail on the donkey" this isn't it? ;-)

"Somewhere in my code, this error is raised. Discuss." lol.

The specific code from the event procedures which are employed around that form's actions could be instructive. Does it happen for all users? Can you reproduce it?

FWIW the CurrentDb scope phenominon is quite quantifiable.
It's true that it doesn't always create a persisted parent object for it's DAO child collection objects, and so always using an object variable is a safe guard.
We went on about it over at UA a while ago.

But suffice to say, it should occur consistently - depending upon the objects being operated upon.

Cheers.
 
Last edited by a moderator:

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:50
Joined
Sep 12, 2006
Messages
14,630
It is rather "pin the tail on the donkey" this isn't it? ;-)

"Somewhere in my code, this error is raised. Discuss." lol.

The specific code from the event procedures which are employed around that form's actions could be instructive. Does it happen for all users? Can you reproduce it?

FWIW the CurrentDb scope phenominon is quite quantifiable.
It's true that it doesn't always create a persisted parent object for it's DAO child collection objects, and so always using an object variable is a safe guard.
We went on about it over at UA a while ago.

But suffice to say, it should occur consistently - depending upon the objects being operated upon.

Cheers.

That's a better way to put it, technically, Leigh!

and the referenced thread seems equally technical!
 
Last edited:

LPurvis

AWF VIP
Local time
Today, 04:50
Joined
Jun 16, 2008
Messages
1,269
And quite long. :)
To summarise, different DAO objects behave differently with regard to persistence.
As a very general rule, objects what represent data (as opposed to vessels which return it) require persistence.
Whereas Recordsets and QueryDefs don't require a persisted parent database object.

The thread's there for any interested.
Or you can just always use a Database object variable. ;-)

Cheers.
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 04:50
Joined
Sep 12, 2006
Messages
14,630
and of course its always just

currentdb.execute etc

so its the DAO references that cause the trouble.
 

NauticalGent

CopyPaster of the First Order
Local time
Yesterday, 23:50
Joined
Apr 27, 2015
Messages
4,162
This topic is discussed here. It evens references this thread, which is how I found it in the first place. Thought I would close the loop...
 

theDBguy

I’m here to help
Staff member
Local time
Yesterday, 20:50
Joined
Oct 29, 2018
Messages
16,584
Just FYI. I fixed the link to UA in post #7. Cheers!
 

Isaac

Lifelong Learner
Local time
Yesterday, 20:50
Joined
Mar 14, 2017
Messages
5,774

See the one and only 'comment' after the article you linked to, which did 10x more than the article did to explain it
(Although I have no idea if anything they posted was right - don't know one way or the other).
 

NauticalGent

CopyPaster of the First Order
Local time
Yesterday, 23:50
Joined
Apr 27, 2015
Messages
4,162
See the one and only 'comment' after the article you linked to, which did 10x more than the article did to explain it
(Although I have no idea if anything they posted was right - don't know one way or the other).
Completely missed that, thanks for clarifying.
 

Users who are viewing this thread

Top Bottom