Solved

Updating Records in multiple tables

Posted on 2006-10-26
5
298 Views
Last Modified: 2012-06-27
I have a form which enters a customers address details in a table. It then asks if you would like to add the address into another table ( job address table).

The problem I have is, is that these records can then be edited (individually). How can I make it so that if one of the addresses (multiple fields) is edited, it will automatically uupdate the same record in the other table?

Thanks
0
Comment
Question by:vibale
5 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 17815668
create table relationship

set the referntial integrity
Cascade delete
cascade update
0
 

Author Comment

by:vibale
ID: 17815707
Yeah but the records arent exactly the same, one table has a couple of extra fields, will it still work?
0
 
LVL 74

Accepted Solution

by:
Jeffrey Coachman earned 250 total points
ID: 18034771
vibale,

Another way to look at this is to re-think your system for "Adding" the address to another table.

The rules of database design dictate that data should only be stored once. (you key in the address once and it only gets stored in that one place)

You can use a query to "display" the address fields in another table (so the Address data will always be the same in both places).

Here is a simple example:
Table Name:  tblEmployees
Fields:
EmployeeID (PK)
FirstName
LastName
Address
City
Region
PostalCode

Your table with the "extra" fields: tblEmployeeExtra
Fields:
EmpExtraID (PK)
EmployeeID (FK)
BloodPressure
BloodSugar

Create a query to join these two tables on "EmployeeID": qryEmployeeExtra

SELECT tblEmployees.EmployeeID, tblEmployees.LastName, tblEmployees.FirstName, tblEmployees.Address, tblEmployees.City, tblEmployees.Region, tblEmployees.PostalCode, tblEmployeeExtra.BloodPressure, tblEmployeeExtra.BloodSugar
FROM tblEmployees LEFT JOIN tblEmployeeExtra ON tblEmployees.EmployeeID = tblEmployeeExtra.EmployeeID;

So if you change any address info in tblEmployees, it is reflected in this qryEmployeeExtra query.

When you need to update the "extra fields" simply create a main/subform (tblEmployees as the main and tblEmployeeExtra as the sub)

Hope this helps as well

Good luck

0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

726 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