Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

MS Access form  Parent - Child Link fields problem

Posted on 2016-09-14
2
Medium Priority
?
261 Views
Last Modified: 2016-09-15
I am working on database that somebody else created before. It is created in access 2003.I am trying to understand what is happening but some things are confusing.

 In this database I have Parent – Child (Main form – Sub Form) environment. Something similar to Order and line item situation.
Those two forms are linked with three fields.
Link1
Link2
Link3

They are bound forms.
Parent form frmMain is bound to tblParent and  sub form frmSubForm is bound to query Qry_Child.
Query Qry_Child is composed from two tables: tblParent and tblChild fields.

In query Qry_Child tables are connected with left join on those three fields that are link fields for the sub form and exist in both tables.
I want to point out something about those three linking fields between frmMain and frmSubMain.
Sub form frmSubFrom is based on Qry_Child and in Qry_Child those three fields are not from tblChild (even they exist there) but  they are from tblMain.
So my question is which link fields are in form Parent – Child link used here.
Are link fields from tblMain and tblChild  those filed used for  join in query or those from frmSubForm that is based on Qry_Child. Again I am pointing out that those three fields in Query are brought in from tblMain not from tblChild.

I am asking this as I have problem when I run this database on PC that has MS access 2003 and change value of Link2 field on frmMain it changes value of field Link2 in tblChild.
However if I run the same database on PC that has Access 2010 and I change value of link2 field on frmMain  I lost data on my sub form frmSubForm it is blank as no fields showing,  just all area where sub form was  is flat gray.
Only difference on Main form between these two database is that in 2010 database main form frmMain Link2 field is seating now on form tab Control that was not existed in 2003 version.

Not sure what is happening?
0
Comment
Question by:Taras
2 Comments
 
LVL 40

Accepted Solution

by:
PatHartman earned 2000 total points
ID: 41798741
Sometimes bugs are fixed from one version to the next and other times edits are tightened up.  Both can cause differences in execution.  Your problem is that the original form was incorrectly defined and an earlier version of Access was compensating for you.

1. The subform query will almost never need to join to the parent table.  So remove the parent table.
2. If you, because of some strange circumstance that I just cannot imagine, decide that you must keep the parent table in the subform query, DO NOT select the "key" fields from the parent table.  They must be selected from the child table.

The master/child links are used by Access to control populating the foreign key in the subform.  So in the case of something like tblOrder and tblOrderDetails.  The primary key of tblOrder is OrderID.  The primary key of tblOrderDetails is OrderDetailsID.  The foreign key to the order table in tblOrderDetails is OrderID.   The Master/child link field will be OrderID from the master and OrderID from the Child.  When you insert a row in the child table using the subform, it is the Master/child link definition that enables Access to populate the OrderID in the details table with the OrderID from the parent table.  Because you have chosen "OrderID" from the parent table in your subform query, Access cannot populate OrderID in the child table - you didn't include it.  I have no idea why an earlier version of Access allowed you to get away with this.  I would say THAT was the bug and the current version is working correctly.
0
 

Author Closing Comment

by:Taras
ID: 41800421
Thanks Pat.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
We live in a world of interfaces like the one in the title picture. VBA also allows to use interfaces which offers a lot of possibilities. This article describes how to use interfaces in VBA and how to work around their bugs.
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 how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …

916 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