Solved

Index or Primary Key Cannot Contain A Null Value

Posted on 2011-02-19
5
653 Views
Last Modified: 2012-05-11
See attached form frmPrices.

I cannot seem to add a record in here. I get the error;

"Index or Primary Key Cannot Contain A Null Value"

Why?
(It may have to do with my indexes on tblPrices??)
Database1.mdb
0
Comment
Question by:Patrick O'Dea
5 Comments
 
LVL 75

Assisted Solution

by:DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform)
DatabaseMX (Joe Anderson - Microsoft MVP, Access and Data Platform) earned 166 total points
ID: 34934683
Yes it does.  I made the AutoNumber the Primary Key - as it should be.

attached.
Database1-MX01.zip
0
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 167 total points
ID: 34934684
please check the table the form frmPrices is bound to.
that table has primary key and/or unique index(es) [which are not auto-number]
those fields cannot be null, so you need to check if the form sets values for all those fields [again: with exception of the field that is autonumber]
the error message tells you that you are missing (at least) one such field
0
 
LVL 120

Assisted Solution

by:Rey Obrero (Capricorn1)
Rey Obrero (Capricorn1) earned 167 total points
ID: 34934685
you have three indexes in table tblPrice that does not allow null vlaues

CurrencyCode
PriceID
SupplierID
ProductCode
0
 

Author Closing Comment

by:Patrick O'Dea
ID: 34934698
Thanks all!

I shouldl have spotted the error my self!
0
 
LVL 75
ID: 34934699
Here is another version with a Unique Index on your original two fields that were the Primary Key before - in case that is what you need ... see attached and image.

mx
Database1-MX02.zip
Capture1.gif
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In earlier versions of Windows (XP and before), you could drag a database to the taskbar, where it would appear as a taskbar icon to open that database.  This article shows how to recreate this functionality in Windows 7 through 10.
Did you know that more than 4 billion data records have been recorded as lost or stolen since 2013? It was a staggering number brought to our attention during last week’s ManageEngine webinar, where attendees received a comprehensive look at the ma…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

713 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question