423,851 Members | 2,680 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,851 IT Pros & Developers. It's quick & easy.

Meaning of "Object Invalid or no longer set"?

P: n/a
I'm getting intermittent "Object Invalid or No Longer Set" errors in my
Access 2002 mdb.

What causes these errors?

Has anyone dealt with this before?

I can't trace it because it's not easy to duplicate -- it just show up...

I've heard that spurious queries that use Now() or Date() or some other date
function can cause this error. ???

Any suggestions welcome!!

Thanks!
Nov 12 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Here's what I've found so far:

http://support.microsoft.com/default...b;en-us;243459

http://support.microsoft.com/default...roduct=acc2000

also something about the the latest Jet service pack ... which I think I
already have
"deko" <dj****@hotmail.com> wrote in message
news:zC***********@newssvr27.news.prodigy.com...
I'm getting intermittent "Object Invalid or No Longer Set" errors in my
Access 2002 mdb.

What causes these errors?

Has anyone dealt with this before?

I can't trace it because it's not easy to duplicate -- it just show up...

I've heard that spurious queries that use Now() or Date() or some other date function can cause this error. ???

Any suggestions welcome!!

Thanks!

Nov 12 '05 #2

P: n/a
Although my scenario is different, it's similar enough for me to think that
this might be it... comments welcome!!

(below taken from Microsoft Knowledge Base Article - 200592)

The following example attempts to use the CurrentDb function to return a
pointer to the database that is currently open in Microsoft Access. Because
the code does not assign that database to an object variable, the pointer
returned by the CurrentDb function is temporary and becomes invalid after
the TableDef object is set. Consequently, any later references in your code
to the TableDef object variable will result in an error.
1.. Start Access and open the sample database Northwind.mdb.
2.. Create a module and type the following procedure:
Sub CurrentDbFail()
Dim td As DAO.TableDef
Set td = CurrentDb.TableDefs("Customers")
MsgBox td.Name
End Sub 3.. To test this procedure, type the following line in the
Immediate window, and then press ENTER:
CurrentDbFail Note you receive the error described in the Symptoms
section of this article
"deko" <dj****@hotmail.com> wrote in message
news:zC***********@newssvr27.news.prodigy.com...
I'm getting intermittent "Object Invalid or No Longer Set" errors in my
Access 2002 mdb.

What causes these errors?

Has anyone dealt with this before?

I can't trace it because it's not easy to duplicate -- it just show up...

I've heard that spurious queries that use Now() or Date() or some other date function can cause this error. ???

Any suggestions welcome!!

Thanks!

Nov 12 '05 #3

P: n/a
This is the recordset operation I'm using:

Public Sub SyncForms()
Dim lngEid As Long
Me.Requery
lngEid = Form_frmCn.Entity_ID
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.FindFirst ("Entity_ID=" & lngEid)
If rst.NoMatch Then
MsgBox ("Can't find Entity ID " &
Forms!frmMain!frmCn!Entity_ID), , "Error Ac84"
Else
Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing
End Sub
What this does is move the current form to the record that was being viewed
(the current record) in frmCn -- which is a form that it part of a series of
tabbed forms. So, when the user selects a record from a list on frmCn, and
then changes tabs, SyncForms is called and the database moves to that record
in the new form (frmTx). The problem seems to arise when changes are made
to the data in frmTx...

or perhaps I'm totally wrong, and it's something else...

"deko" <dj****@hotmail.com> wrote in message
news:zC***********@newssvr27.news.prodigy.com...
I'm getting intermittent "Object Invalid or No Longer Set" errors in my
Access 2002 mdb.

What causes these errors?

Has anyone dealt with this before?

I can't trace it because it's not easy to duplicate -- it just show up...

I've heard that spurious queries that use Now() or Date() or some other date function can cause this error. ???

Any suggestions welcome!!

Thanks!

Nov 12 '05 #4

P: n/a
TS

"deko" <dj****@hotmail.com> wrote in message
news:zC***********@newssvr27.news.prodigy.com...
I'm getting intermittent "Object Invalid or No Longer Set" errors in my
Access 2002 mdb.

What causes these errors?

Has anyone dealt with this before?

I can't trace it because it's not easy to duplicate -- it just show up...

I've heard that spurious queries that use Now() or Date() or some other date function can cause this error. ???

Any suggestions welcome!!

Thanks!

I'm assuming you are getting this in your VB code. Try commenting out your
"on error" statement so when the error occurs it will put you on the
offending line. You are probably trying to close or reference an object
that is not open.

If it is a connection you are closing, for example, try:

If conn.state = AdStateOpen then conn.close

Hope this helps
Ken
Nov 12 '05 #5

P: n/a
> lngEid = Form_frmCn.Entity_ID

That should be:

lngEid = Forms!frmCn.Entity_ID

.... or ...

lngEid = Forms("frmCn").Entity_ID
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.FindFirst ("Entity_ID=" & lngEid)
If rst.NoMatch Then
MsgBox ("Can't find Entity ID " &
Forms!frmMain!frmCn!Entity_ID), , "Error Ac84"
Else


You also need to take another look at your MsgBox () syntax, because it is
incorrect. You need to remove the parentheses as these are required only when
you are retrieving the value returned from the MsgBox() function, as in:

If MsgBox("Can you answer this question?", vbYesNo) = vbYes
'You answered "Yes"
Else
'You answered "No"
End If

--
Bruce M. Thompson
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #6

P: n/a
Thanks for the tips, and I will correct my syntax, but I don't think that is
the casue of the problem.

I've narrowed it down to a Datasheet form that has a query as a
recordsource -- if I make changes (in-cell editing) to the datasheet, and
then change to a different tab in my tabbed form set, and back, I get the
Invalid Object error.

I'm not sure if I need to requery, reassign the recordsource, or both, after
something is changed in the Datasheet:

Private Sub Form_AfterUpdate()
modAssign.Modified 'updates modification date
Me.Requery
Me.RecordSource = "qryTxHist_Ac"
End Sub

In any case, I am still fighting that elusive enemy "Object Invalid or No
Longer Set" -- a.k.a Run-time error '3420'

any help is greatly appreciated!

"Bruce M. Thompson" <bthmpson@big_NOSPAM_foot.com> wrote in message
news:vo************@corp.supernews.com...
lngEid = Form_frmCn.Entity_ID
That should be:

lngEid = Forms!frmCn.Entity_ID

... or ...

lngEid = Forms("frmCn").Entity_ID
Dim rst As DAO.Recordset
Set rst = Me.RecordsetClone
rst.FindFirst ("Entity_ID=" & lngEid)
If rst.NoMatch Then
MsgBox ("Can't find Entity ID " &
Forms!frmMain!frmCn!Entity_ID), , "Error Ac84"
Else


You also need to take another look at your MsgBox () syntax, because it is
incorrect. You need to remove the parentheses as these are required only

when you are retrieving the value returned from the MsgBox() function, as in:

If MsgBox("Can you answer this question?", vbYesNo) = vbYes
'You answered "Yes"
Else
'You answered "No"
End If

--
Bruce M. Thompson
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<

Nov 12 '05 #7

P: n/a
> Thanks for the tips, and I will correct my syntax, but I don't think that is
the casue of the problem.
Well, it certainly could be the cause of *some* problems because numerous parts
of your code would not have run as written. If this was caused by typos while
typing the code into the message (as opposed to copying from the subroutine and
then pasting to the message) then this would not be an issue.
I've narrowed it down to a Datasheet form that has a query as a
recordsource -- if I make changes (in-cell editing) to the datasheet, and
then change to a different tab in my tabbed form set, and back, I get the
Invalid Object error.
I suspect that you need to examine your forms' modules for any other code that
might contain errors. If this is not the case, your project might be in need of
compacting or, possibly, decompiling. There is a "decompile" switch (available
in Access 97, 2000 and, apparently, 2002) that can be used to help correct this
situation, but this is more of a "last resort" in that there is some risk to the
file as described in http://www.trigeminal.com/usenet/usenet004.asp?1033 (so ...
work with a copy of the file). Further information is available at
http://www.databasecreations.com/Dat...rmanceTips.pdf. The procedure I
use when implementing this is as follows:

1) BACK UP YOUR MDB FILE!
1) BACK UP YOUR MDB FILE! (I meant it the first time <g>)
2) Compact the MDB.
3) Implement the "/decompile" as described in the articles I referenced.
(Access 2000, and later, don't provide the confirmation dialog that
existed in Access 97, but the decompile will still take place.)
4) Open Access normally and compact the MDB again to clean up.
5) Compile and save.
6) Compact again before testing/using.
I'm not sure if I need to requery, reassign the recordsource, or both, after
something is changed in the Datasheet:
Neither should be necessary.
Private Sub Form_AfterUpdate()
modAssign.Modified 'updates modification date


How, exactly, does this update a field's value? You didn't mention this before.
Was this added after you posted the message to which I last replied?

--
Bruce M. Thompson
bt******@mvps.org (See the Access FAQ at http://www.mvps.org/access)
NO Email Please. Keep all communications

within the newsgroups so that all might benefit.<<
Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.