I want to use my own primary key but I keep getting this message. Index or primary kdy cannot contain a null value.
I want to use my own primary key but I keep getting this message. Index or primary kdy cannot contain a null value.
When do you get the message?
I suspect that in the Table that is giving you this message, you have a field that is designated as either a Primary Key - or as 'Indexed'.
That means that one of the records has no value in that field.
these are the steps I am taking: External data, excel, browse, import to current database, next, check the first row contains column headings, next, Indexed is set at no, choose my own primary key, next, import to table1, finish, and then comes the message. Index or primary key cannot contain a null value.
I would import the spreadsheet without the primary key and verify that a) you're only pulling in Rows that have data. b) that the column you are specifying as the Primary Key is fully populated for each row.
I think that the problem is:
1. You have a field in your table designated as a Primary Key - or a field in your table that has the Required Property set to Yes.
2. There are Null values in the spreadsheet for that field in your table - and when Access sees the Null in the spreadsheet - and the 'Required' in your table - it is rejecting it.
What I usually do is import the spreadsheet into a new table in the database.
Then I say 'No Primary Key.
My Priority is to get ALL the data from the spreadsheet in my table. I can deal with Nulls etc once I have the data safely in my database.
I've found that when I've tried to get fancy and change table properties - and then try and import spreadsheets into it - I run in to problems.
Hope this helps!
After completing the import without the Primary key create a query to pull in all records where the field you want to use for the primary key is null and see if you're returning any rows.
If you are importing into an existing table, the table may already have a PK or index defined, and as others have said, you're importing at least one record with no value(NULL) in that field.
You could make sure the field involved is fully populated before doing the import.
Or,you could import to a new temp table with no key or indexes; then review the data to ensure the field is populated(no NULLs); then append the Temp Table records to the original (existing) table.
Just my $.02
Good luck.
EDIT: I see others have posted since I started typing.
I have verified each row in the spreadsheet and they all have data.
Using no primary key has worked for importing my spreadsheet. Now how do i create my primary key?
I tried going to the design view and highlighting the Field name, and adding the key to that, when I did, I get the same message. hmmm.
Sort Ascending by that field in the table and see the first row has a null.
Last edited by Robeen; 09-23-2011 at 02:30 PM. Reason: Typo.