Results 1 to 10 of 10
  1. #1
    Sandsnake is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    6

    index or primary key cannot contain a null value


    Hiya

    I am about to start a ropeless bungee jumping club, so any help would be super appreciated.

    I am trying to create a new record entry form. It loads via a command button from a home form. Then when i try to save it, it tells me that the primary index cannot be null. I have essentially replicated a process i used earlier, but which is now not working at all. I have tried hiding the index, but to no avail. If i show it, it seems to require the user to enter the index number, which is bad (TM). I cannot seem to get the index to autonumber, any ideas? any details required will be provided, but not sure what to give.

    Thanks for any help

    EDIT:

    When I launch the NEW_PATIENT_ENTRY form, it tells me that the record is not open, this might be the problem that the table is not being loaded. But unsure how to laod the table record. The form for new patient was created via the wizard using the PATIENT table as a base

  2. #2
    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,722
    We need to see more info --- perhaps a table or a jpg of the table structure...

  3. #3
    Sandsnake is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    6
    Quote Originally Posted by orange View Post
    We need to see more info --- perhaps a table or a jpg of the table structure...
    Okay, I zipped and added the entire database.

  4. #4
    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,722
    Not everyone has acc2007 or acc2010, so can not open the accdb.

  5. #5
    Sandsnake is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    6
    Quote Originally Posted by orange View Post
    Not everyone has acc2007 or acc2010, so can not open the accdb.
    So here is the table and the macro from the button that is giving me the grief

    EDIT: and the relationships table too
    Last edited by Sandsnake; 07-12-2011 at 07:10 AM. Reason: more pics

  6. #6
    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,722
    What are the data types of the ID fields? If these are autonumber, then Access will assign these automatically. Also, when using autonumber PK, be aware that numbers are NOT NECESSARILY contiguous. They may be, and usually are, but Access just ensures they are unique (not sequential). Also, when an autonumber is used, it is used and the next assignment will be a new number.

    I don't have 2010 and I don't use Macros, so I'm not sure what the issue is. It is a fact that a Primary Key can not contain NULLs.

    How did you create your form? Did you use a wizard to create a bound form?

  7. #7
    Sandsnake is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    6
    Quote Originally Posted by orange View Post
    What are the data types of the ID fields? If these are autonumber, then Access will assign these automatically. Also, when using autonumber PK, be aware that numbers are NOT NECESSARILY contiguous. They may be, and usually are, but Access just ensures they are unique (not sequential). Also, when an autonumber is used, it is used and the next assignment will be a new number.
    Am aware that contiguity is not implicit, that is not the issue.

    Quote Originally Posted by orange View Post
    I don't have 2010 and I don't use Macros, so I'm not sure what the issue is. It is a fact that a Primary Key can not contain NULLs.
    This is obvious, the error message is simple to understand in meaning, it is just the specific reason that is elusive.

    Quote Originally Posted by orange View Post
    How did you create your form? Did you use a wizard to create a bound form?
    Yes, i Used a wizard, not sure what the bound means tho?

    TO clarify my original point, the error is not if 9 try to do a backend save on the table. That works. No problems. The error occurs when i try to save the form that is supposed to write to the table. I think the new patient form is not correctly loading the patient table.

  8. #8
    kimmer is offline Competent Performer
    Windows 7 Access 2010 (version 14.0)
    Join Date
    May 2010
    Posts
    100
    Your ID field in the PATIENT table is not an autonumber; you have it set as a double. Either change the data type to autonumber, or put a control for the ID field on the form so users can enter the value.
    Last edited by kimmer; 07-12-2011 at 01:32 PM. Reason: fear of the typo popo :)

  9. #9
    Sandsnake is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    6
    Quote Originally Posted by kimmer View Post
    Your ID field in the PATIENT table is not an autonumber; you have it set as a double. Either change the data type to autonumber, or put a control for the ID field on the form so users can enter the value.
    Ah man!!!! it seems the way i carried the data across from the previous version changed the number types. okay, makes sense now, thank you

  10. #10
    Sandsnake is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2011
    Posts
    6
    Ok, so the problem was that when the tables got exported to Excel, they lost the value for the indices, so i fixed by recreating the db from scratch and altering the way the import was done by re-adding the indices new.

    Now i still only have the problem that when i click on the add new patient form on the front page to add a new page, the button goes to the correct form, which has been created by wizard and is bound to the correct table, but it does not open the record.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-11-2011, 01:43 PM
  2. index/primary cannot contain null value
    By BinHDreW in forum Access
    Replies: 1
    Last Post: 05-26-2011, 08:25 PM
  3. Replies: 2
    Last Post: 01-03-2011, 05:17 PM
  4. Replies: 1
    Last Post: 08-03-2010, 01:33 PM
  5. Replies: 6
    Last Post: 02-19-2010, 03:52 PM

Tags for this Thread

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