Subforms are not members of the Forms collection. You need to refer to them
via their parent form ...
Forms("NameOfParentForm").Controls("NameOfSubformControl").Form.RecordSource
If the code is running from the parent form, you can shorten this to ...
Me!NameOfSubfromControl.Form.RecordSource
>I have a form that displays a bunch of information to the user. On the
>form,
[quoted text clipped - 20 lines]
>
> end sub
Brandan,
At the time of the change in the record source, their parent form has not
yet been loaded. Plus, I would think I would get the same error, regardless
which of the two buttons I clicked, but I don't. With one button, the forms
load properly, with the other, I get the error message. I have not tried
this yet, but now that I think about it, the one that does not generate the
error has the same recordsource as the default for those forms, so maybe it
isn't updating the recordsource in either instance.
> Subforms are not members of the Forms collection. You need to refer to them
> via their parent form ...
[quoted text clipped - 29 lines]
> >
> > end sub
Brendan Reynolds - 29 Mar 2005 09:25 GMT
Subforms, or, to be more specific, forms which are being used as the
SourceObject of a subform control, are not members of the Forms collection,
so if code similar to that which you posted is working, the forms in
question are not being used as subforms in this specific sense - perhaps you
are using the term differently?

Signature
Brendan Reynolds (MVP)
> Brandan,
>
[quoted text clipped - 45 lines]
>> >
>> > end sub
Dale Fye - 30 Mar 2005 02:17 GMT
Brendan,
Got it. I moved the code for the recordsource to the Open event of the main
form, and passed it a value in the OpenArgs parameter of the the OpenForms
method.
Thanks for the help.
Dale
> Subforms, or, to be more specific, forms which are being used as the
> SourceObject of a subform control, are not members of the Forms
[quoted text clipped - 54 lines]
>>> >
>>> > end sub