Fix the Null Value Primary Key Error in Microsoft Access
Question details
Resolve the error that appears when creating a primary key in Microsoft Access.

- Product
- Microsoft Access
- Device & OS
- not provided
- Scenario
- A user is trying to set an existing table field as the primary key.
- Observed behavior
- Access reports that an index or primary key cannot contain a null value, and changing the Indexed property does not resolve the error.
Identify the table and field you want to use as the primary key. Check whether the field is intended to uniquely identify every record before changing its values.
Remove Null and Duplicate Values from the Primary Key Field
Use this solution when an existing field should identify each record but Access will not accept it as the primary key.
A primary key must contain a unique, non-null value for every record. Changing the Indexed property does not correct values already stored in the table.
Open the table in Datasheet View and inspect the proposed key field for empty cells. For a larger table, select Create > Query Design, add the table and key field, enter Is Null in the field's Criteria row, and click Run.
Select Create > Query Wizard > Find Duplicates Query Wizard. Choose the table and the proposed key field, then run the query to identify repeated values.
Open the table in Datasheet View and replace null or blank entries with appropriate unique values. Correct duplicate values or, if appropriate, delete affected records after checking that they are no longer needed.
Open the table in Design View, select the corrected field, and click Primary Key on the ribbon. Save the table and confirm that the error no longer appears.

Review Exported Access Data with WPS Spreadsheets
WPS Office is a free, lightweight Office alternative with a familiar interface and Microsoft Office format compatibility for easy migration. Use WPS Spreadsheets to review exported table data; the primary key itself must still be corrected in Access.

Frequently Asked Questions
Why does Access reject my primary key?
The proposed key field may contain Null values or duplicates. Use Create > Query Design with the Is Null criterion and the Find Duplicates Query Wizard to locate problem records.
Why didn't changing the Indexed property fix the error?
Changing the Indexed property does not replace Null values or correct duplicates already in the table. Fix those values before selecting the field and clicking Primary Key in Design View.
How do I find duplicate values in Access?
Select Create > Query Wizard > Find Duplicates Query Wizard, choose the table and proposed key field, and run the query.
Is a blank text value the same as Null?
No. An empty string and Null are different in Access, so inspect visually blank text entries separately from records returned by an Is Null query.
Can WPS Office fix an Access primary key?
No. WPS Spreadsheets can help you review exported data, but you must correct the records and create the primary key in Microsoft Access.




