How to Link Tables in MS Access
Linking tables through relationships is what transforms a collection of spreadsheets into a relational database. When tblOrders references tblCustomers through CustomerID, you can run queries that join customer names with their orders without duplicating data.
Example Tables
- tblCustomers:CustomerID (PK), FirstName, LastName, Email
- tblOrders:OrderID (PK), CustomerID (FK), OrderDate, TotalAmount
- tblOrderDetails:DetailID (PK), OrderID (FK), ProductID (FK), Quantity, UnitPrice
Create a Relationship in the Relationships Window
- Go to Database Tools → Relationships.
- Add tblCustomers and tblOrders to the window.
- Drag CustomerID from tblCustomers onto CustomerID in tblOrders.
- Select 'Enforce Referential Integrity' in the dialog.
- Choose Cascade Update Related Fields if CustomerID values may change.
- Click Create and save the relationship layout.
Understanding Relationship Types
- One-to-Many:One customer has many orders. This is the most common relationship in Access.
- One-to-One:Rare — used when splitting a wide table into two related tables.
- Many-to-Many:Requires a junction table (e.g., tblProductCategories linking Products and Categories).
Referential Integrity Rules
Enforcing referential integrity prevents orphaned records. Access will block you from:
- Adding an order with a CustomerID that does not exist in tblCustomers.
- Deleting a customer who still has orders (unless Cascade Delete is enabled).
Query Across Linked Tables
Once relationships exist, create a query joining tblCustomers and tblOrders to produce a customer order history report. Add indexes on all foreign key fields for faster joins — see our query optimization guide.
