I am trying to set the recordset of a subform that is part of a parent form.
The code that I am using is:
docmd.openform "mainFrm"
Forms!mainFrm.subFrm.Form.RecordSource = "SELECT * FROM table1 WHERE ID = 24;"
I get the following error:
Application-defined or object defined error
If I change the vba to:
docmd.openform "subFrm"
Forms!subFrm.RecordSource = "SELECT * FROM table1 WHERE ID = 24;"
The subform opens fine.
One thing that I have noticed is that even though SubFrm
is part of the mainFrm
. Even when the mainFrm
is open:
?CurrentProject.AllForms("SubFrm").IsLoaded
returns false
Even though
?CurrentProject.AllForms("MainFrm").IsLoaded
returns true
Is there a way to change the recordset of a sub form that is part of a main form while the main form is open?