Solved

How do you connect two tables in a form so that they are in sync when the form is used

Posted on 2012-04-07
8
310 Views
Last Modified: 2012-04-10
I have two tables a Header and Detail table I have the primary key in the header table and the primary key in the detail table.

My question is how do I connect them together so that they show up when a form is entered and records are entered in both the header and the detail section. I am a beginner so I have learned the table building but do not know nor have ever seen how to connect them so they show up in sync on a form page.

I know it has something to do with the background SQL and tying it together. I am clueless how that works. Please advise. Any examples or video is really helpful. Thank you.
0
Comment
Question by:ruavol2
  • 2
  • 2
  • 2
  • +2
8 Comments
 
LVL 77

Assisted Solution

by:peter57r
peter57r earned 100 total points
Comment Utility
For this table structure you typically use a form consisting of a  main form containing a subform.

You create a main form based on the header table.

Then you create another form based on the detail table.  (In due course thiss will be placed o your main form as a subform- as below).

Then you add a subform control to your main form and the wizard guides you through the process, in which you select the form to be used (your detail form) and how the main form and subform link together.
0
 
LVL 119

Accepted Solution

by:
Rey Obrero earned 100 total points
Comment Utility
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 200 total points
Comment Utility
Assume the tables:
A (a, r, x) - primary key (a)
a r
1 a1
2 a2

B(a, b, r) - primary key (a,b)
a b r
1 1 b11
1 2 b12
2 1 b21

When you create a form based on table A (bound to table A), you get the default text boxes a and r. Let's call it frmA
The same for a form bound on table B, you get the default text field names a, b,  and r. Let's call it frmB.

Open form frmA in design mode, and drag frmB on it in the detail section, this frmB is now encapsulated in a control (subform control) with the default name frmB. The wizard if it is activated, will ask for the master link fields, and child link fields. Select a for master, and a for child the link is established.

If the form fields are renamed, the link keys has to be changed to the new names.
0
 

Author Comment

by:ruavol2
Comment Utility
I do not know if you guys have any knowledge of this but when I use the instructions from above everything looks good right up until I try to enter the sub form. Then I get the following error message and I do not know how to get past it. Can you tell me what is blocking it. I am not seeing it. Please advise. Else I can post a new question if it is not related. Thank you.
AccessError.png
0
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
LVL 119

Expert Comment

by:Rey Obrero
Comment Utility
it will help if you can upload the db you are working on.
0
 
LVL 30

Assisted Solution

by:hnasr
hnasr earned 200 total points
Comment Utility
Find Msaccess.exe
Right click the icon  and select Run as administrator.
Open database. Check and comment.
0
 
LVL 74

Assisted Solution

by:Jeffrey Coachman
Jeffrey Coachman earned 100 total points
Comment Utility
ruavol2,

I am confused by your request.

First, can you please put real names on these very vague "Detail" and "Header" tables...

Customers/Orders?
Employees/Sales?
Orders/Parts?

Typically you already have all the "Parent" records and you are simply entering the "Child" records...
So I am not clear on what you mean by:
"and records are entered in both the header and the detail section."

Here is a very basic sample in addition to the info already posted

In this case the Main/subform setup that the previous experts mentioned seems to be what you need.
0
 

Author Closing Comment

by:ruavol2
Comment Utility
I got it to work. Thank you for your help.
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

728 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

13 Experts available now in Live!

Get 1:1 Help Now