How to Design and Update Junction Tables in Microsoft Access
Question details
Learn how to design a junction table for a many-to-many relationship and add or update its records.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- Two tables need to be connected through a junction table, with relationships entered through forms, queries, or code.
- Observed behavior
- The junction table stores each relationship as a record containing foreign keys from both source tables and, optionally, attributes of that relationship.
Identify the primary key in each source table and decide whether each pair of records should appear only once in the junction table. Check that the junction table's foreign-key data types match the referenced keys; an AutoNumber key typically uses a Number field with the Long Integer field size.
Create a Junction Table and Update It Through a Subform
Use this approach when users need to create relationships and enter relationship details through an Access form.
A junction table contains a foreign key for each source table. It can also store attributes of the relationship, such as quantity or the unit price recorded at the time of an order.
Adding records to the source tables does not automatically create a junction-table record. The relationship must be entered separately.
Select Create > Table Design. Add a foreign-key field for each source table and any relationship fields you need. Set the two foreign-key fields as a composite primary key, or use a separate primary key and create a unique composite index on the pair.
Open Database Tools > Relationships, add the three tables, and connect each source table's primary key to its corresponding junction-table field. Select Enforce Referential Integrity when creating each relationship, then save the layout.
Create a form whose Record Source is the junction table. Add it as a subform to a form bound to one source table, and set the subform control's Link Master Fields and Link Child Fields properties to the matching parent key and junction-table foreign key.
In the subform's Design View, add a combo box that lists records from the other source table. Set its Control Source to the corresponding junction-table foreign-key field and configure its row source to include the key and a recognizable display value.
Open the parent form in Form View, add a row in the subform, select the related record from the combo box, and enter any relationship attributes. Save the record to insert the junction-table row.

Add Junction-Table Records With an Append Query
Use an append query when you need to insert one or more relationship records from existing data.
Work With Office Files Alongside Your Access Database
WPS Office is a free, lightweight alternative for everyday document, spreadsheet, and presentation work. Its familiar interface and Microsoft Office format compatibility make it easy to move existing files into your workflow. It does not replace Microsoft Access or manage Access junction tables.

Frequently Asked Questions
Does adding records to both source tables automatically create a relationship?
No. Add a record containing both foreign keys to the junction table through a bound form, an append query, or VBA code.
How do I prevent duplicate relationships in a junction table?
In Table Design, make the two foreign-key fields a composite primary key, or create a unique composite index on the pair. A separate primary key alone does not prevent duplicate pairs.
Which table should the subform be bound to?
Set the subform's Record Source to the junction table. Use a combo box whose Control Source is the junction table's foreign-key field to select a record from the other source table.
Can a junction table store more than two foreign keys?
Yes. It can also contain fields describing the relationship, such as quantity or historical unit price. Add those fields in Table Design and include them on the bound subform if users need to edit them.
What if a combo box does not contain the record I need?
Add the record to its referenced table using an appropriate form. You can configure the combo box's NotInList event or List Items Edit Form property to help users add missing choices, then requery the combo box and select the new record.




