Results 1 to 7 of 7
  1. #1
    bigsich is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    8

    New record error in form, but not table

    Hi,

    I have a form for data entry including a button for a new project. The records are autonumbered, but this field is not displayed in the form. When I create a new record in the table for the form, I don't get any errors. However, when I create the new record through the form, i get the "Indexed or primary key cannot contain a null value". I click ok, and everything works fine. I check the table, and the autonumber field has worked. I tried to compact and repair the database, but that didn't fix it. Any help appreciated. Thanks!

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Indexed columns within your table must contain a value for each field.

    Go to your table. Make a list of all the fields where the property for indexed is "Yes".

    Go to your form with the problem. Place all of the fields on your "Indexed List" in your problem form.

    Open your form and include a value in all of the fields within your "Indexed List" before moving to the next record or closing your form.

  3. #3
    bigsich is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    8
    That's what I can't figure out. The only field that is indexed is the primary key, which is autonumbered. Having that field appear in the form does not fix the problem.

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Does not make much sense then. Is the form based on a query? Take a look at the query and try to add a new record. Perhaps the problem is in a joined table's indexed field. Perhaps it is a referential integrity rule within your relationships window.

    After that, why do you have a control button that creates a new project? Hopefully this code is not associated with the symptom you are currently experiencing.

  5. #5
    Dal Jeanis is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Dallas TX
    Posts
    1,742
    1) What code is the button is using to create the new record?
    2) Did you mean, you get an error but the error did not prevent the record from being added?

  6. #6
    bigsich is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2012
    Posts
    8
    A couple of the fields pull information from a query, but the problem started before them. I've got a stable version, and the relationships are the same. I will play around with it tonight and see if I can get it to work. I checked all the relationships and indexed fields in the linked tables, and everything works fine. It's weird that it works in the table, but not the form. I've got the same form structure that drive other tables, and they work fine (i.e. PK not appearing in form, using autonumber, button to create new record).

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by bigsich View Post
    (i.e. PK not appearing in form, using autonumber, button to create new record).
    Correct, these items should not be part of the issue. I would take a look at the query to verify your perception of the chronology is not skewed.

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

Similar Threads

  1. Replies: 3
    Last Post: 03-09-2013, 10:39 AM
  2. Replies: 3
    Last Post: 02-06-2013, 07:23 PM
  3. Replies: 4
    Last Post: 08-14-2012, 07:14 AM
  4. Replies: 12
    Last Post: 09-09-2011, 11:14 AM
  5. Replies: 8
    Last Post: 05-12-2011, 06:11 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