Solved

Index or Primary Key Cannot Contain A Null Value

Posted on 2011-02-19
5
648 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 - Access MVP)
DatabaseMX (Joe Anderson - Access MVP) 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 142

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 119

Assisted Solution

by:Rey Obrero
Rey Obrero 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

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

757 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now