ACC2002: Trigger Returns an Error That User Has Deleted Record or Changed Primary Key (275064)
The information in this article applies to:
This article was previously published under Q275064 Advanced: Requires expert coding, interoperability, and multiuser
skills.
This article applies only to a Microsoft Access project (.adp).
SYMPTOMS When you try to delete a record from a table that contains
a trigger that is designed to delete records from another table, you receive
the following error message: Another user or application
has deleted this record or changed the value of its primary key.
CAUSE You have created tables that are related in a one-to-many
relationship. You have also created a trigger on the one-sided table. The
trigger is designed to automatically remove child records from the many-sided
table whenever a parent record is removed from the one-sided table. If child
records exist on the many-side, the trigger functions as expected. But if there
are no child records to match the parent record, the trigger fails, and you
receive the error message that is mentioned in the "Symptoms" section of this
article. RESOLUTION Use the following trigger:
Alter Trigger Suppliers_Trigger1
On Suppliers
For Delete
As
If (SELECT COUNT(*) FROM Products, Deleted WHERE Products.SupplierID = Deleted.SupplierID) > 0
BEGIN
DELETE Products FROM Deleted, Suppliers WHERE Products.SupplierID = Deleted.SupplierID
End
REFERENCESFor
more information about triggers, click Microsoft Access Help on the Help menu, type create a trigger in the Office
Assistant or the Answer Wizard, and then click Search to view the topics returned.
Modification Type: | Minor | Last Reviewed: | 1/26/2005 |
---|
Keywords: | kberrmsg kbpending kbprb KB275064 |
---|
|