By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,483 Members | 1,506 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,483 IT Pros & Developers. It's quick & easy.

Subform's record source

P: n/a
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?
Jul 14 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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?

Jul 14 '06 #2

P: n/a
The link master and child fields will be the same for all iterations of
this...if access doesn't do too much guessing I should be ok?

Thanks for the reply.

"Allen Browne" <Al*********@SeeSig.Invalidwrote in message
news:44***********************@per-qv1-newsreader-01.iinet.net.au...
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?


Jul 14 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.