Solved

Explanation of Master/Subform and PK/FK Link fields

Posted on 2004-09-02
6
1,104 Views
Last Modified: 2008-07-14
I need an explanation of how Master/Subform works and how to link the forms.
I have 2 tables. They are related by orderid.  Orderid is 1 to many from Main to Multiplelinetable.
Main = orderid  
Multipleline = orderid.
When I create a Main form and add Multiple Line as a subform, when I add a new record to Main, and then a new record to multipleline, the orderid is not being put into the multipleline table. Hence, they are not linked.
I read about PK/FK and Master and Child fields, and it seems that the child field should be automatically populated but I have no idea what I am doing wrong. Please explain how it works.
0
Comment
Question by:jykler
6 Comments
 
LVL 2

Expert Comment

by:wblakely
Comment Utility
On the properties for the "Multiple Line" subform, did you fill in "Link Child Fields" and "Link Master Fields" with "orderid"?
0
 

Author Comment

by:jykler
Comment Utility
Oh yes, of course :)
It doesn't seem to be linking though. DO I put the name of the table field, the name of the field on the page? What place do I put it to make it put the correct field in the table?
How should the underlying query look? Should it include both tables? Should that be set to the master form? or the child form? I don't understand the concepts.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 250 total points
Comment Utility
i think this will give you a good overview of the main/subform

Create a form and a subform at the same time

In the Database window, click Forms  under Objects.
Click the New button on the Database window toolbar.
In the New Form dialog box, double-click Form Wizard.
In the first wizard dialog box, select a table or query from the list. For example, to create a Categories form that displays products for each category in a subform, select the Categories table (the "one" side of the one-to-many relationship).
Note   It doesn't matter which table or query you choose first.

Double-click the fields you want to include from this table or query.
In the same wizard dialog box, select another table or query from the list. Using the same example, select the Products table (the "many" side of the one-to-many relationship).
Double-click the fields you want to include from this table or query.
When you click Next, if you set up the relationships correctly before starting the wizard, the wizard asks which table or query you want to view by. Using the same example, to create the Categories form, click By Categories.
In the same wizard dialog box, select the Form With subform(s) option.
Follow the directions in the remaining wizard dialog boxes. When you click Finish, Microsoft Access creates two forms, one for the main form and subform control, and one for the subform.
0
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 
LVL 4

Assisted Solution

by:naivad
naivad earned 250 total points
Comment Utility
Here is a trick I use:

Choose a form that you want for a parent form. Open it in design view. Switch to Database Window. Drag the form you want to be used as a child form onto the design view of the parent form. Drop. It should automatically select the relationships needed if there are similar field names used in pk/fk relationships.

I find this easier than using the subform control on the toolbox.

After the relationship is defined, then you should be able to look at the property settings to see what access did.

Hope this helps.

0
 

Author Comment

by:jykler
Comment Utility
Thanks for the options. We will try them out, I will be out of the office until Tues Sept 7. When I get back I will try and let you know how things went and put the pts in.
0
 

Author Comment

by:jykler
Comment Utility
Thanks! We got the program working.. Appreciate all the help you guys give..
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
Regardless of which version on MS Access you are using, one of the harder data-entry forms to create is one where most data from previous entries needs to be appended to new records, especially when there are numerous fields and records involved.  W…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now