Results 1 to 7 of 7
  1. #1
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72

    Primary Key can not contain a null value

    I am far from an expert w/Access 2003 but I have managed to create a database. I use forms to add data to tables. The main form is Orders where I enter an OrderID. I use a command button to launch the next form where I add WorkOrders associated with the OrderID. I set up the


    WorkOrders form to pull the OrderID from the main form and populate that
    field. The workorders table primary key is a field called SID which I fill in
    manually (at this stage, later to be autonumber). After filling in all data in the WorkOrders form and hit "enter" or install a "Save" command button Access comes back with "Primary key can not contain a null value", when obviously the PK value is not null.

    I'm doing all of this with no knowledge of VB code, just using wizzards and modifying properties. Any basic help is appreciated.

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Why is this field not an AutoNumber field now? What are you waiting for?

  3. #3
    ConneXionLost's Avatar
    ConneXionLost is offline Simulacrum
    Windows XP Access 2007
    Join Date
    Jan 2010
    Location
    Victoria, Canada
    Posts
    291
    Hi Bruce,

    Check to ensure your main "Orders" form has saved the record (and created the OrderID) before you launch the next form.

    Cheers,

  4. #4
    rwp289 is offline Novice
    Windows XP Access 2007
    Join Date
    Jan 2010
    Posts
    4
    Start with the basics:

    Are you sure that the textbox that you are entering the SID (your Workorders PK) is actual bound to SID field in the Workorders table?

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    I think the OP has gone on vacation.

  6. #6
    Bruce is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Nov 2009
    Posts
    72
    Sorry, forgot to come back after finding the answer. I was binding the text field to the value on another open form instead of using VB to set the value of the field. Once I bound the text field to the table and coded the value to equal (on load) the value of the textbox on the other form, it worked.

    Learning more as time passes. Thanks!

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 Access 2007
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Great! Thanks for the update.

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

Similar Threads

  1. Primary Key Issue
    By Ciwan in forum Access
    Replies: 5
    Last Post: 10-23-2009, 10:04 PM
  2. Primary Key Help
    By phoenix13 in forum Access
    Replies: 4
    Last Post: 07-30-2009, 12:36 PM
  3. about the primary key!
    By Yuesko in forum Access
    Replies: 1
    Last Post: 05-29-2009, 04:20 PM
  4. reset primary key
    By emilylu3 in forum Access
    Replies: 1
    Last Post: 12-09-2005, 03:27 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