2467: Object Doesn't Exist..... But it does.... really.... Ithink....

  • Thread starter Thread starter PeteCresswell
  • Start date Start date
P

PeteCresswell

Code looks like this:
---------------------------------------------------------------------------------------
3130 WorkTable_Create
"ttblSecurity_AddBuyClone_LadderParents",
zmtblSecurity_AddBuyClone_LadderParents"
3131 CurrentDb.Execute
"qrySecurity_AddBuyClone_LadderParents_Populate", dbFailOnError
3132 .subLadderParents.Form.RecordSource =
"qrySecurity_AddBuyClone_LadderParents_Display"
3139 .subLadderParents.Visible = True
---------------------------------------------------------------------------------------

It's creating a work table, populating it, and then setting a
subform's .RecordSource to a query that reads the table.

Stepping through the code:

Pausing at line 3132
- I can open up that query and see a bona-fide recordset.
- I can see .subLadderParents.Name via the Immediate window
- But when I try to get to .Form.Name in the Immediate window it
dies with the same "2467" error.

Needless to say, it dies at line 3132 with "2467: Expression you
entered refers to an object that is closed or doesn't exist."

Seems like I've been here before, but I can't recall what the issue
was.
 
Hi Pete,

I *think* the issue is CurrentDB. Try this modification:

Dim db As DAO.Database
Set db = CurrentDB()

3131 db.Execute ("qrySecurity_AddBuyClone_LadderParents_Populate",
dbFailOnError)


In the ExitProc: section, make sure to issue Set db = Nothing
to help clean up object variables.

Reference:
http://support.microsoft.com/kb/200592/


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
Hi Pete,

I *think* the issue is CurrentDB. Try this modification:

Dim db As DAO.Database
Set db = CurrentDB()

Nice try, but no cigar..... -)

FWIW, the error message isn't quite the same as the MS article
cites.
Heaven forbid they should accompany it with a number....

I used to do the "Set thisDB=CurrentDB()" thing religiously based on
the belief that CurrentDB() refreshed some list of objects every time
it was called and calling it just once was theoretically time-
saving. For reasons forgotten, I've drifted away from that
practice.

Could this issue be anything to do with the form's Dirty flag?
 
Also, the subfordm object seems to know about the form, as in:

?forms!frmSecurity_AddBuyClone!subLadderParents.sourceobject
frmSecurity_AddBuyClone_LadderParents

But
?forms!frmSecurity_AddBuyClone!subLadderParents.form.name
throws a 2467.
 
I found it.

The subform's .RecordSource was getting set in code - as shown.

But it looks like Yours Truly had somehow managed to fat-finger a
paste and, instead of being blank at the beginning of it all, the
subform's .RecordSource was set to the name of a text box elsewhere on
the form.
 
I'm not sure what you are saying here, but a subform that is open in a main
form is not in the forms collection. For example, try the following
experiment in the sample Northwind.mdb database:

1.) Open the Orders form. This form includes a subform named "Orders
Subform". Leave this form open for step 2.

2.) Open the Immediate Window <Ctrl><G>. We are using the IsLoaded function,
which is found in the module named Utility Functions:

? IsLoaded("Orders")
True

? IsLoaded("Orders Subform")
False


You could insert a line of code in the Current_Event of the subform to print
it's parent form's name (Debug.Print Me.Parent).


Tom Wickerath
Microsoft Access MVP
http://www.accessmvp.com/TWickerath/
http://www.access.qbuilt.com/html/expert_contributors.html
__________________________________________
 
m:
Code looks like this:
-------------------------------------------------------------------
-------------------- 3130 WorkTable_Create
"ttblSecurity_AddBuyClone_LadderParents",
zmtblSecurity_AddBuyClone_LadderParents"
3131 CurrentDb.Execute
"qrySecurity_AddBuyClone_LadderParents_Populate", dbFailOnError
3132 .subLadderParents.Form.RecordSource =
"qrySecurity_AddBuyClone_LadderParents_Display"
3139 .subLadderParents.Visible = True
-------------------------------------------------------------------
--------------------

It's creating a work table, populating it, and then setting a
subform's .RecordSource to a query that reads the table.

Stepping through the code:

Pausing at line 3132
- I can open up that query and see a bona-fide recordset.
- I can see .subLadderParents.Name via the Immediate window
- But when I try to get to .Form.Name in the Immediate window
it
dies with the same "2467" error.

Needless to say, it dies at line 3132 with "2467: Expression you
entered refers to an object that is closed or doesn't exist."

Seems like I've been here before, but I can't recall what the
issue was.

If you're using a db variable, maybe you need to issue:

db.QueryDefs.Refresh

OR

db.TableDefs.Refresh

in order for the collections to reflect the changes you've made to
those collections since you initialized your database variable.

In other words, if you do this:

Set db = CurrentDB

then all collections are current at that point.

If you then execute SQL that creates a new table or you write a new
QueryDef, the TableDef and QueryDef collections of your db variable
will not be current until you refresh those collections.

db.QueryDefs.Refresh
db.TableDefs.Refresh

Using the db variable does *not* refresh its collections.
 
Back
Top