Page 1 of 2 12 LastLast
Results 1 to 15 of 19
  1. #1
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11

    Primary Key

    I want to use my own primary key but I keep getting this message. Index or primary kdy cannot contain a null value.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    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'.

  3. #3
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11

    Error message

    When I am trying to choose my own Primary Key during the import spreadsheet wizard.


    Quote Originally Posted by Robeen View Post
    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'.

  4. #4
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    That means that one of the records has no value in that field.

  5. #5
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11
    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.

  6. #6
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11

    records with no values

    When I checked my excel spreadsheet that I am importing, i see all of the values there>
    Quote Originally Posted by RayMilhon View Post
    That means that one of the records has no value in that field.

  7. #7
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    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.

  8. #8
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11

    records

    When I let Access choose the key for me, i don't get an error.

    Quote Originally Posted by RayMilhon View Post
    That means that one of the records has no value in that field.

  9. #9
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    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!

  10. #10
    RayMilhon is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    1,067
    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.

  11. #11
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    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.

  12. #12
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11

    primary key

    I have verified each row in the spreadsheet and they all have data.

    Quote Originally Posted by RayMilhon View Post
    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.

  13. #13
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11
    Using no primary key has worked for importing my spreadsheet. Now how do i create my primary key?

  14. #14
    DukeBlue is offline Novice
    Windows XP Access 2010 32bit
    Join Date
    Sep 2011
    Posts
    11
    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.

  15. #15
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    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.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Triple primary key
    By snoopy2003 in forum Database Design
    Replies: 1
    Last Post: 02-23-2011, 09:18 AM
  2. Replies: 6
    Last Post: 02-19-2010, 03:52 PM
  3. Primary Key Issue
    By Ciwan in forum Access
    Replies: 5
    Last Post: 10-23-2009, 10:04 PM
  4. Primary Key Help
    By phoenix13 in forum Access
    Replies: 4
    Last Post: 07-30-2009, 12:36 PM
  5. about the primary key!
    By Yuesko in forum Access
    Replies: 1
    Last Post: 05-29-2009, 04:20 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums