Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Index or Primary Key Cannot Contain A Null Value

Posted on 2011-02-19
5
Medium Priority
?
669 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 664 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 668 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 668 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 learning courses: Active Directory Deep Dive

Get a firm grasp on your IT environment when you learn Active Directory best practices with Veeam! Watch all, or choose any amount, of this three-part webinar series to improve your skills. From the basics to virtualization and backup, we got you covered.

Question has a verified solution.

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

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Traditionally, the method to display pictures in Access forms and reports is to first download them from URLs to a folder, record the path in a table and then let the form or report pull the pictures from that folder. But why not let Windows retr…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

885 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