ACC: Nulls Allowed in Foreign Key with Referential IntegrityLast reviewed: January 5, 1998Article ID: Q98789 |
The information in this article applies to:
SUMMARYNovice: Requires knowledge of the user interface on single-user computers. Microsoft Access allows a Null value in a field that is the foreign key in a relationship if referential integrity is enforced. To prevent users from leaving the foreign key blank in Microsoft Access 97, 7.0, or 2.0, set its Required property to Yes. To prevent users from leaving the foreign key blank in Microsoft Access version 1.x, add a table level validation rule to the table on the many side of the relationship. For an example, see the "Steps to Reproduce Behavior" section.
MORE INFORMATIONThis behavior occurs whether you use a single-field primary key and foreign key or a multiple-field primary key and foreign key. However, Microsoft Access versions 7.0 and later allow a Null value in a field that is part of a multiple-field foreign key only if every other field of the foreign key also contains a Null value. If at least one field of the foreign key contains a Null value and at least one other field of the foreign key contains data, you receive the following error when you try to save the record.
In Microsoft Access 7.0 ----------------------- Can't add or change record. Referential integrity rules require a related record in table <one-side table>. In Microsoft Access 97 ---------------------- You can't add or change a record because a related record is required in table <one-side table>.This behavior differs from that of earlier versions of Microsoft Access. Microsoft Access version 2.0 allows you to save a record in which at least one field of the foreign key contains a Null value and at least one other field of the foreign key contains data. For more information about Null values and multiple-field foreign keys in Microsoft Access versions 7.0 and later, please see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q170779 TITLE : ACC: Inconsistent Behavior with Multiple-Field Primary Key Steps to Reproduce BehaviorCAUTION: Following the steps in this example will modify the sample database Northwind.mdb (or NWIND.MDB in version 2.0 or earlier). You may want to back up the Northwind.mdb (or NWIND.MDB) file and perform these steps on a copy of the database.
REFERENCESFor more information about data integrity, search the Help Index for "referential integrity," and then "What is referential integrity" or ask the Microsoft Access 97 Office Assistant.
|
Additional query words: null compact cascade
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |