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!

Referential Integrity Problem

Status
Not open for further replies.

burritonator

IS-IT--Management
Jun 15, 2004
133
US
The Access database that I am working on contains a table called "Devices" and another called "Hardware". The Hardware records contain a Foreign Key that links to the Primary Key of a Devices record. I have that relationaship set up, with Referential Integretity enforced ("Cascade Update Related Fields" and "Cascade Delete Related Fields" are not selected.)

I just discovered that Access will not allow me to either delete or modify a record in the Devices table if there are related records in the Hardware table. This is the desired behavior as it pertains to deletions. However, I need for the user to be able to modify records in the Devices table even if there are related records in the Hardware table. I do not understand why Access will not allow this, as I did not think that referential integrity rules would be violated when Device records are updated as long as the value of the Primary key doesn't change.

Is there a way that I can enforce referential integrity in such a way that record deletions in the primary table are not allowed if there are related records in other tables, while still allowing modifications to be made to records in the primary table?

Thanks,
Burritonator
 
Records can be modified. Except the primary key or the fields that make a unique index and are used in a one-to-one/many relationship. Or your changes would duplicate the index.

Or...the database is corrupted...

HTH


[pipe]
Daniel Vlas
Systems Consultant

 
Dan -- you are back!

How is the new (now old?) job??

Burritonator
Is it possible you have a query and are trying to edit the data on the one-side table (device) and the many-side table (hardware) at the same time.

If so, a better approach is to edit one table at a time. For example, change the owner of the device -- this will not affect the "hardware".

You can also change the "hardware" such as add memory -- this will not affect the "device".

But when you try to change the device (eg. owner) and the hardware (eg. memory), Access may give you a rough time.

Richard
 
I figured out the cause of the problem that I was having. Whenever a record was modified, the value of the Primary key was being overwritten. It wasn't actually being changed to a different value, but I assume that the fact that a value was being written to the key field was enough to cause Access to mark the field as having been modified.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top