affect same data in column at linked two Table (1 Viewer)

mhakim

Member
Local time
Today, 11:20
Joined
Jan 25, 2021
Messages
72
hi dears
good day

i have table Header and Cloumn called Branch_id
and
i have table Details and Cloumn Called Branch_id

form like Invoice Headers and Details

i use one form to insert data to Header & Details (Header one record primary key and Details many records as Subform forein key) primary key is different or it is not Branch_id

so i need to chose Branch_id in form in Header Part and then it will affect Branch_id in subform Details with same value with out manual chose Branch_id again in the Subform
 

Edgar_

Active member
Local time
Today, 03:20
Joined
Jul 8, 2023
Messages
430
If form has subform, choose subform > in properties pane choose data > link master and child forms > click ellipsis (the dots) choose Branch_id in both and it will link the forms

So if you change record in form, you will see children to that record only in subform
 

mhakim

Member
Local time
Today, 11:20
Joined
Jan 25, 2021
Messages
72
If form has subform, choose subform > in properties pane choose data > link master and child forms > click ellipsis (the dots) choose Branch_id in both and it will link the forms

So if you change record in form, you will see children to that record only in subform

very good
thanks

but
i already have two mandatory fields Linked
so how can i manage another two fields
 

CJ_London

Super Moderator
Staff member
Local time
Today, 09:20
Joined
Feb 19, 2013
Messages
16,612
You can use multiple fields- just separate with a semi colon

linkmaster - field1;field2
Linkchild- field1;field2
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:20
Joined
Feb 19, 2002
Messages
43,275
so how can i manage another two fields
You should NOT duplicate data. Since the data is the same for All records of a set, the values belong in the parent table. There is no need to equivocate. It is 100% wrong to duplicate this data in the child table. The only time you would have branch_Id in the child records is if it could be different for different child rows and in that case, it would be 100% wrong to have branch_id in the header table.

In a parent/child relationship the ONLY field that is "duplicated" is the PK-FK. The PK of the parent table is stored as the FK in the child table so you can tell what parent each child record belongs to. When you need to display any data from the parent table, you do so by creating a query that joins the parent to the child so you can pick columns from either table to display.

Also, rather than using a multi-column PK for the parent, it will be far easier using Access if you create an autonumber and use that as the PK. Then to enforce business rules, you might need to create a unique multi-column index by using the indexes dialog. You cannot create multi-column indexes using the table gui. You must use the indexes dialog. In Access forms, we use a lot of combo boxes. You need a single-field unique value to use a combo so if your PK is multi-column, you can't use combo boxes to select an item.
 
Last edited:

mike60smart

Registered User.
Local time
Today, 09:20
Joined
Aug 6, 2017
Messages
1,905
It might help if you upload a copy of the database.
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 04:20
Joined
Feb 19, 2002
Messages
43,275
Multiple fields work fine with master/child links but they don't work with combos or listboxes. That is where you will have trouble with multi-field PKs.
 

Users who are viewing this thread

Top Bottom