Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem updating records after enforcing referential integrity

Status
Not open for further replies.

Tyskie19

Technical User
Feb 13, 2005
14
CA
I used to be able to do this (or at least I think I did). What I did was I added a field to a table. I named this table the same as the primary key in another table, and then enforced referential integrity. Everything works...but the problem is the new table does not have the values that exist in the other table for this ID. How do i update the related table so that the field I created will have the same values as those in the primary table?
 
With Referential integrity, the parent record has to exist before creating the child record.

For example, using a team and a player on the team
A team has to exist before a player can be assigned to the team.

The typical approach is to use the Form / SubForm as described by BNPMike.

Another approach is to use a form based on the "child" table, and use a combo box to select the record from the the "parent" table.

Richard
 
I want the values to be the same, not different. For instance I am using the field CustomerID as a primary key in one field (autonumber), what I tried doing is creating that field in another table to create a foreign key and enforce referential integrity. The problem is the values in the related table are all null, and I cannot get them to equal the values of the ones in the related table.
 
the field CustomerID as a primary key in one field
just for clarification, a primary key is defined for a table, not a field.

So, let's say you have:

tableCustomer
CustomerID (PK - Autonumber)
other customer info

tableOrders
OrderID (PK)
CustomerID (FK - Long Integer)

now you are trying to insert your key where?



Leslie

In times of universal deceit, telling the truth will be a revolutionary act. - George Orwell
 
IN order to do this, the tables will have to have some field in common. If they do, a simple update query between the two tables will work.

In query design view, place both tables. Join them on the common field that BOTH tables have values for.

IN the grid, you want to update the FK on the "many" side to the PK on the "one" side.

If the two tables do not have any common fields, you will probably have to use eyes and brains to update.

Frank kegley
fkegley@hotmail.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top