Try:
Me.[sub1].Form.RecordSource = "Query1"
where sub1 represents the name of the subform control.
If the .Form bit is new to you, see:
http://allenbrowne.com/casu-04.html
Basically, the subform control does not have a RecordSource; the form in the
subform control does.
If it still fails, perhaps the Name of the subform control is different than
the name of the form it contains.
When you change the RecordSource, Access will have a guess at the
LinkMasterFields/LinkChildFields, but it may not be what you want.
--
Allen Browne - Microsoft MVP. Perth, Western Australia.
Tips for Access users -
http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.
"shifty shaker" <SS***@pioneers.netwrote in message
news:i_*****************@news02.roc.ny...
>I need to get at a subofmr's recordsource in code. I want to change the
recordsource dynamically. I thought this would be straight forward..but I
keep getting errors.
On Event
forms!Mainform!subform!recordsource = "somequery"
End sub
I've also tried variations of this Me.subforms.recordsource
and Forms!mainform.subform.recordsource..
returns various errors such as object doesn support this propery etc.
I'm guessing I'm just not getting the syntax right or something.
Anyone see where I'm going wrong?