Two form load methods:
1) Open the main form from the Project Window.
2) Open the main form from an AutoExec macro - the main form containing the subform is loaded using DoCmd.OpenForm method and setting Form_frmMyMainForm.Visible = True.
When the main form has been opened from the Project window I can set the RecordSource property of the subform using the following:
Form_sfrMySubForm.RecordSource = "SELECT ..."
and it works. If I execute the same line of code when the main form has been opened with the AutoExec macro the above line does not work. However this line does:
Form_frmMyMainForm.sfrMySubForm.Form.RecordSource = "SELECT ..."
Why does opening the main form from the Project window allow me to implicitly reference the subform while if I load the main form myself I can't? In my quest for answers I compared the properties of the unqualified subform object after loading and found these differences (the first value listed is from the load via the project window, the second value from the AutoExec method):
PageLogicalWidth = 0|9360
Parent = Valid Object|Nothing
Printer = Nothing|Valid Object
Visible = True|False
What I am really after here is the correct method to use to load a form. In other words, when I load a form from VBA I should be able to produce the same results as when loaded via the Project window, right? Or am I placing too much faith on Access always doing the right thing?