Results 1 to 11 of 11
  1. #1
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    Entering data into to eh tabel the first time

    I am entering test data into my db, just to test it out. I am glad that I did since, I have found several inconsistencies (errors if you will). The first table
    let us call it personnel table obviously has a primary key and a many foreign keys that are connected to primary keys in other tables.

    Now I am entering some data to show db operation and to see if it works. It has been easy until I get to a foreign key. Then it generates an error that says



    You cannot change a record because a related record is required in tables "tblOrg".



    Yes, the foreign key is in tblPersonnel and the primary key is in tblOrg.

    But you must start entering data somewhere and the tblPersonnel is where I chose to start.

    However, if there is a foreign key there and I enter data it generates the above entry. So how do I overcome this.

    Must I enter data (actually the same data) into the table with the primary key first? is there another way?

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou_Reed

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 8 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    What makes you think these are errors?
    I have found several inconsistencies (errors if you will).
    Consider the logic of entering a Child record before entering a Parent record?


    You enter data into the independent table before the dependent table.

  3. #3
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    It make sense what you say. It is just in most of my tutorials that I have studied this never came up.
    It does seem logical to enter data into parent record and then enter data into child record.

    As I said it just never came up in the tutorials.

    Anyway, thanks for your help.


    Respectfully,

    Lou_Reed

  4. #4
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    In the tblContracts I entered a value 0 for no contracts (the primary key), but it is actually value; it just that says no contacts exist.

    That was the parent table - the tblContracts and it only has one entry, which as I said is 0.


    Then I went to table personnel and tried to enter for each person in the tblPersonnel. the value 0 (
    the foreign key) for contracts.

    It said that I cannot add or change a record because a related record is required in tblContracts. But as I said I had already entered the contacts value which I sat at 0.


    What is going on? I put the data in the primary key first, then the foreign key.

    Any help appreciated. Thanks in advance.

    Respectfully,


    Lou_Reed

  5. #5
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Go to the relationships diagram and check the relationship between tblPersonnel and tblContracts - does it join the two on the correct fields?

  6. #6
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I will check it. I think it does because the line has already been drawn connecting the two. Access 2010 would not have let me draw that line if
    the data fields had been different. I will try what you said.

    I will get back with the results.


    Respectfully,


    Lou_Reed

  7. #7
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    The foreign key for Contracts is the Number field and the primary key for contracts is Autonumber field.

    So yes the fields are the same.

    What could be wrong?


    Respectfully,

    Lou_Reed

  8. #8
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    I noticed that I have only a single entry for the primary key, and multiple entries for the foreign key. This as it should be.

    It is called a 1 to many relation.

    Still the software will not let me input values first for the parent table and second for the child table.

    This is confusing.

    Respectfully,


    Lou_Reed

  9. #9
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Is a previous post you stated:

    In the tblContracts I entered a value 0 for no contracts (the primary key),
    If the PK in that table (tblcontracts) is AutoNumber, you could not have done that, because you cannot enter your own value into an autonumber field.

    Can you post of list of your tables and their fields? It would help.

  10. #10
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664

    This is teh file thta cannot link Contract_ID in the two tables

    I think that the attached zip files is shown above. As I said it cannot do tblContracts and tblPersonnel.

    Any help on this issue appreciated.


    Thanks in advance.
    Attached Files Attached Files

  11. #11
    Lou_Reed is offline VIP
    Windows 7 64bit Access 2010 64bit
    Join Date
    Mar 2015
    Posts
    1,664
    Looks like you are right. Once, I change my foreign key to reflect the primary (which is never zero), it worked.

    Thanks for your help.

    Respectfully,


    Lou_Reed

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

Similar Threads

  1. Replies: 3
    Last Post: 05-07-2015, 05:37 AM
  2. Replies: 1
    Last Post: 03-20-2013, 02:57 AM
  3. Replies: 3
    Last Post: 10-01-2012, 04:43 PM
  4. Replies: 2
    Last Post: 04-24-2012, 01:26 PM
  5. Automatically enter today's date when entering time
    By Szabi in forum Database Design
    Replies: 5
    Last Post: 03-16-2012, 03:50 AM

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