Solved

Index or Primary Key Cannot Contain A Null Value

Posted on 2011-02-19
5
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
print previewing the record showing on the form 4 51
Balance After Payment 12 62
access vba 5 57
office 2016 license quastion 3 44
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
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…

738 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