Can record source for subform be query?

  • Thread starter Thread starter David
  • Start date Start date
D

David

Can my record source for a subform be a query?
If so, how do I get the query to run off of the primary
key of the current record in my main form?

I need information from 2 tables to populate the subform.
 
All you need to do for that is create a query for the subform with one
of the fields being the PK that is used in the main form.
The simple way of thinking about a subform is that it is in fact a fully
independent form, based on a query (or whatever else). You can open it
separately from the main form and you will see all records in it. But
when it is used as a subform, it gets filtered by the value of the
Parent field in the current record of the Main form.

Pavel
 
Sounds simple, why do I find it so confusing?
The child and master links confuse me, what do I put in
them. I tried the Access 'suggestions' and none of them
are what I want. The documentation on these links is vague
to say the least.
David
 
David said:
Sounds simple, why do I find it so confusing?
The child and master links confuse me, what do I put in
them. I tried the Access 'suggestions' and none of them
are what I want. The documentation on these links is vague
to say the least.
David

The data in the subform and parent form must have one or more fields in
common (the fields that make up the relationship between the two). Those
fields are what you normally place in the MasterLink and ChildLink
properties of the subform control.

Simple Example:

Sales Order parent form with sub-form showing the items ordered. The field
[OrderNumber] would exist in both tables and forms and that is what would
be used for the MasterLink and ChildLink properties. That causes the
subform to be filtered so that only line-items for the order currently
displayed in the parent form are shown.
 
I understand all that but I don't have a direct link, the
link is via a third table. So I'm confused as to what to
put in the links.
I have:
table 1 ProjectID
table 2 AssignmentID
table 3 CommentID
There is a one-to-many between 1 and 2 and between 2 and 3.
My subform needs to show all Comment records for the
Project. The ProjectID is not in the Comment table.
-----Original Message-----
David said:
Sounds simple, why do I find it so confusing?
The child and master links confuse me, what do I put in
them. I tried the Access 'suggestions' and none of them
are what I want. The documentation on these links is vague
to say the least.
David

The data in the subform and parent form must have one or more fields in
common (the fields that make up the relationship between the two). Those
fields are what you normally place in the MasterLink and ChildLink
properties of the subform control.

Simple Example:

Sales Order parent form with sub-form showing the items ordered. The field
[OrderNumber] would exist in both tables and forms and that is what would
be used for the MasterLink and ChildLink properties. That causes the
subform to be filtered so that only line-items for the order currently
displayed in the parent form are shown.



--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



.
 
David,

I assume your ProjectID is in the Assignment table, and your
AssignmentID is in the Comment table right? They will have to be
linked that way. Your table relationships will have to be set up that
way as well for this to be done smoothly. In your query you are
combining the Assignment and the Comment tables, right?

The main form's data should come from the Project table. The subform
built from your query should link with the main form when you insert
it, assuming you have your ProjectID field in the query.

Russ


I understand all that but I don't have a direct link, the
link is via a third table. So I'm confused as to what to
put in the links.
I have:
table 1 ProjectID
table 2 AssignmentID
table 3 CommentID
There is a one-to-many between 1 and 2 and between 2 and 3.
My subform needs to show all Comment records for the
Project. The ProjectID is not in the Comment table.
-----Original Message-----
David said:
Sounds simple, why do I find it so confusing?
The child and master links confuse me, what do I put in
them. I tried the Access 'suggestions' and none of them
are what I want. The documentation on these links is vague
to say the least.
David

The data in the subform and parent form must have one or more fields in
common (the fields that make up the relationship between the two). Those
fields are what you normally place in the MasterLink and ChildLink
properties of the subform control.

Simple Example:

Sales Order parent form with sub-form showing the items ordered. The field
[OrderNumber] would exist in both tables and forms and that is what would
be used for the MasterLink and ChildLink properties. That causes the
subform to be filtered so that only line-items for the order currently
displayed in the parent form are shown.



--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com



.
 
Back
Top