1

I have two tables that relate one-to-many in an Access database. The tables are:

tbluser : UserID [Primary Key]

tblproject : UserID [Foreign Key] , PrjID [Primary Key]

I need to prevent users from deleting any records in tbluser that have related records in the tblproject table.

4

2 回答 2

2

You need to create a Relationship in the Access database and select the "Enforce Referential Integrity" option:

Relationship.png

For detailed instructions on creating Relationships in Access, look here:

Create, edit or delete a relationship

于 2013-11-10T23:01:00.853 回答
0

如果您在 tblproject(UserID) 上定义了引用 tbluser(UserID) 的外键约束,则任何用户都无法从 tblproject 中删除该用户,它会抛出一个错误,说明某些内容"Value referencing in tbluser".

于 2013-11-10T21:02:23.467 回答