Display Child Records in subform

Z

Zorkmid

I have a Db with a parent-child setup.

I want to build a form that will allow me to select a parent record, and
display the child record (there may be more than one) in a subform for
editing purposes. I can't figure out how to get the combo box in my main form
to populate the subform with its child records. Any ideas?

I have a combo box that allows me to select a unique field in the parent
table, but I dont know how to get it to populate the subform. I think I need
some afterupdate code or something?

-Z
 
K

Kipp Woodard

Use the LinkMasterFields and the LinkChildFields properties of the SubForm
control.

The value for the LinkMasterFields property will be the name of your
comboBox control. The name for the LinkChildFields property will be the name
of the field in the subform that is the link to your main form.
 
A

Albert D. Kallal

Zorkmid said:
I have a Db with a parent-child setup.

I want to build a form that will allow me to select a parent record, and
display the child record (there may be more than one) in a subform for
editing purposes. I can't figure out how to get the combo box in my main
form
to populate the subform with its child records. Any ideas?

I have a combo box that allows me to select a unique field in the parent
table, but I dont know how to get it to populate the subform. I think I
need
some afterupdate code or something?

You should not have to do anything.

So:

Build you main form based on the main (parent) table. DO NOT use a sql join
to bring in child records. Simply build a form on this main table.

To have the form "jump" for move to selected name simply use the combo box
wizard and drop in a combo box (follow the instructions).

Now, create a continues form based on the child table. Again, you can build
this form and base it on the child table. Again, don't use a sql join, nor
try to bring in any fields or parts of the parent table.

It is assumed you also correctly setup the relationship between the two
tables in the relationship window.

Now, bring up your "main" form (the one based on the parent table) in design
mode. Make sure wizard are enabled, and then drop in a sub-form control and
follow the wizard instructions (choose the correct form based on the child
table). Ms-access will setup this for you.

The end result is that if you navigate in the main form, the child form (sub
form) will follow and display the correct child records. and, in place of
using the navigation, if you use the combo box created by the wizard, then
again when the parent form move to a record, the child form will display the
correct records.

All of the above can be done without you having to write one line of code.
 
Z

Zorkmid

Albert D. Kallal said:
You should not have to do anything.

So:

Build you main form based on the main (parent) table. DO NOT use a sql join
to bring in child records. Simply build a form on this main table.

To have the form "jump" for move to selected name simply use the combo box
wizard and drop in a combo box (follow the instructions).

Now, create a continues form based on the child table. Again, you can build
this form and base it on the child table. Again, don't use a sql join, nor
try to bring in any fields or parts of the parent table.

It is assumed you also correctly setup the relationship between the two
tables in the relationship window.

Now, bring up your "main" form (the one based on the parent table) in design
mode. Make sure wizard are enabled, and then drop in a sub-form control and
follow the wizard instructions (choose the correct form based on the child
table). Ms-access will setup this for you.

The end result is that if you navigate in the main form, the child form (sub
form) will follow and display the correct child records. and, in place of
using the navigation, if you use the combo box created by the wizard, then
again when the parent form move to a record, the child form will display the
correct records.

All of the above can be done without you having to write one line of code.


Im not really sure what u mean when you say "create a continous form based
on the child table. I think I made it by pulliung the table into the form.
I alos dont know what you mean by "drop in a sub-form control"

-Z
 
Z

Zorkmid

Kipp Woodard said:
Use the LinkMasterFields and the LinkChildFields properties of the SubForm
control.

The value for the LinkMasterFields property will be the name of your
comboBox control. The name for the LinkChildFields property will be the name
of the field in the subform that is the link to your main form.

Im not sure what you mean really. There are many fields in my subform that
need to link to my main form (they are the fields of the child table)

-Z
 
Z

Zorkmid

It would be really good if there was a way I could show you my DB, its hard
to explain.
 
A

Albert D. Kallal

Im not really sure what u mean when you say "create a continous form based
on the child table.

simply launch the form wizard and follow the instructions. You simply will
create a form based on this child table.

You can choose either Tabular (that is continues form), or you can choose
Datasheet.

(either choice is fine).

so, that is how you create the continues form. (so, a continues form is
really a datasheet, or what the wizard calls Tabular).
I think I made it by pulliung the table into the form.
I alos dont know what you mean by "drop in a sub-form control"

the above is not really any different then dropping on a text box, or check
box, or combo or whatever. You have to just sit down and after you open a
form in design mode you have to learn how to select objects from the tool
box, and drop them onto the form.

As mentioned,, before you create these forms, you should have the table
already created. You also need to have setup a relationship between to the
two tables.

If you want some examples, consider taking a look at some of the sample
templates for access, or the northwind database sample.
http://databases.about.com/od/access/ht/northwind.htm
 

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