Assigning a RecordSource to a subform

G

Guest

I have a form with a subform embedded. The main form needs no record source
because it simply allows the user to input an account name for table lookup
purposes, and the user then clicks a button to display the records. The idea
of the subform, which is in datasheet format, is to display the records
selected based on the user's input in the main form. Obviously a subform
control has no RecordSource property, while the subform itself does. I can
define the RecordSource, but how do I get the subform to display the desired
records? In other words, how do I assign a RecordSource programatically to
the subform?
 
A

Allen Browne

The form in the subform control has a RecordSource, so:
Me.[Sub1].Form.RecordSource = "SELECT ...
where Sub1 represents the name of your subform control.
 
G

Guest

Exactly what I was looking for! I figured this was possible somehow, but had
no idea how to access the form of the subform control.
Thanks.
ctdak


Allen Browne said:
The form in the subform control has a RecordSource, so:
Me.[Sub1].Form.RecordSource = "SELECT ...
where Sub1 represents the name of your subform control.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

ctdak said:
I have a form with a subform embedded. The main form needs no record
source
because it simply allows the user to input an account name for table
lookup
purposes, and the user then clicks a button to display the records. The
idea
of the subform, which is in datasheet format, is to display the records
selected based on the user's input in the main form. Obviously a subform
control has no RecordSource property, while the subform itself does. I
can
define the RecordSource, but how do I get the subform to display the
desired
records? In other words, how do I assign a RecordSource programatically
to
the subform?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top