Join Alicia Katz Pollock for an in-depth discussion in this video Understanding the "Cannot contain a Null value" error, part of Access 2010 Power Shortcuts.
- View Offline
When I am adding records to my database, occasionally an error message pops up that doesn't make much sense. Index or primary key cannot contain a Null value. And when that happens, no matter what you do, it won't let you out. So let's recreate that error. I am in my Customers table and I will make a new blank record, but Tab over your primary key or ID field so that it's left blank. I will fill in a few fields of information. Now, click off the record and the error message pops up. When I click OK and I try and get out again, it still won't let me.
The only thing you can do to get out is to press the Escape key in the upper left corner of your keyboard, but that will erase all the information that you entered. The error is simple but not obvious. As we created the record, we left the primary key filed empty. You didn't enter the ID that distinguishes this record from all the other records in the table. So let's try again. Start with your ID or primary key field and then enter in the rest of the data.
When you move to the next record, this time everything will be fine. I see beginners make this cannot contain a Null value error all the time, and it leaves them flustered and frustrated because the error message itself doesn't help you identify the underlying problem. But once you remember that your table's primary key field is required, it all makes sense. If you are not familiar with primary keys, please see your Access 2010 Essential Training for detailed information.
- Creating new field with field templates
- Understanding errors
- Filtering data
- Aligning and distributing controls
- Customizing the interface
- Navigating quickly between records
- Speeding up data entry
- Analyzing a table for redundant data
- Creating a multi-field primary key
- Moving records with append and delete queries
- Transforming a query into a PivotTable or PivotChart
- Working with images, charts, and Smart Tags in forms
- Hiding duplicates in reports
- Formatting shortcuts
- Using macros