ACC: How to Check for Duplicate Values in Primary Key FieldsLast reviewed: May 14, 1997Article ID: Q102527 |
The information in this article applies to:
SUMMARYModerate: Requires basic macro, coding, and interoperability skills. When you are adding records, Microsoft Access does not normally check the values in primary key fields for duplicates until you move to the next record. If you enter an invalid or duplicate value in a control and move to the next record, you may invalidate all previous entries. However, there is a method to force an immediate check for duplicate values. This article describes how to check for duplicate values immediately.
MORE INFORMATIONThe following example uses the Customers form in the sample database Northwind.mdb in Microsoft Access 7.0 and 97 (NWIND.MDB in Microsoft Access 2.0 or earlier). The Customers form is based on the Customers table; CustomerID is the primary key in the table. NOTE: Microsoft Access 97 has an example of the following in the sample database Northwind.mdb. On the Customers form there is a macro on the BeforeUpdate event of the CustomerId field that verifies that the CustomerId is unique. To force an immediate check for duplicate values, follow these steps: NOTE: CustomerID is called Customer ID in Microsoft Access 2.0 or earlier.
|
Additional query words: count before update fasttips
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |