Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

MS Access form  Parent - Child Link fields problem

Posted on 2016-09-14
2
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 39

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

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

722 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