set recorsource on subform of a subform (1 Viewer)

abenitez77

Registered User.
Local time
Today, 08:08
Joined
Apr 29, 2010
Messages
141
I want to set the recordsource on a GrandChild form:

I tried these 2 ways and i get the error msg: "Run-Time error '2467': The expression you entered refers to an object that is closed or doesn't exist.

I have the code below in the OnChange of the CurrentForm (this is the 1st subform)

Forms(Mainform)(CurrentForm)(SubFormNew).Form.RecordSource = "Dyn_" & project_id & "_SubQryTab05"
Forms!Dyn_163_Workspace!Dyn_163_SubFrmTab05Sec.Form!Dyn_163_SubFrmTab05.Form.RecordSource = "Dyn_" & project_id & "_SubQryTab05"
 

Ranman256

Well-known member
Local time
Today, 08:08
Joined
Apr 9, 2015
Messages
4,339
set the form to a query, not sql.
they work better.
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 08:08
Joined
Oct 17, 2012
Messages
3,276
set the form to a query, not sql.
they work better.

It appears that that is precisely what he's doing: Changing the recordsource for the grandchild form to a table or query whose specific name is determined by the variable or constant 'project_id'.

My first thought is that the grammar was wrong, but it looks okay to me:

Forms!FormName!SubFormControlName.Form!SubSubFormControlName.Form.RecordSource

So to start, I would recommend that the OP confirm that the names of the subform CONTROLS are correct, that project_id has the correct value, and that there really is a query or table named Dyn_<ProjectIDValue>_SubQryTab05.

That error the OP is receiving indicates that either one of the control names is misspelled or else that concatenation at the end is returning a name that doesn't match any table or query in the database.
 

Users who are viewing this thread

Top Bottom