Results 1 to 7 of 7
  1. #1
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48

    Unabe to enter data in the primary key on a form

    Hi,



    I have a split database, but the front-end has additional tables. This should not be a problem as far as I can. I created a Form on the front-end to add records to one of the tables. However, this table is linked to another table that only exist on the front-end database. I can enter all the data on the form, with exception to the Primary Key that links these to tables together.

    It looks like Access does not allow you to enter the primary key data if the tables are linked. Does this mean I have to create to separate forms to add the data. I would like to use one form that will add to both tables simultaneously, thereby avoiding additional work. NB! I use the same logic when updating and it allows me to update the data on both tables using the same form, but when adding, then it will not allow me to enter data into the primary key.

    Your help is much appreciated.

    Thanks
    Earl

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    Need to know the relationship of these tables - one-to-one, one-to-many? Which table is parent and which is child? In parent the key is primary, in the child key is foreign. Is the primary key an Autonumber?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48
    Tbl 1 has fld A as primary key and Tbl2 has fld A as primary key. Tbl1 is parent and there is a one to one relationship

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    A just tested a query joining two tables with one-to-one relationship. No problem entering values into each primary key field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48
    Below is my SQL Statement:

    SELECT PLUData.PLU, PLUData.Code, PLUData.Description, PLUData.Department, PLUData.InvIn, PLUData.Price, PLUData.IsUpDated, tblPLUStockCost.* FROM PLUData INNER JOIN tblPLUStockCost ON PLUData.PLU=tblPLUStockCost.PLU;

    The tables are PLUData (Parent) and tblPLUStockCost (Child). The primary keys have the same field name, i.e. PLU.

    When I select modify using the same form, it allows me to modify both tables and updates both tables simultaneously because primary keys are locked. When I select Add a record, using the same form all the data I can enter, except the primary key on the PLUData, but I can enter the Primary Key on the tblPLUStockCost.

    Could it mean that the one table is updatable, while the other is not, but then it does not explain why the non-primary keys allows entering of data.

    I have now been sitting hours with this... and I will not rest until I can figure it out. I am even considering creating 2 seperate forms to add the data for the 2 tables.

    Any suggestions is much appreciated

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,601
    I cannot replicate your issue. Do you want to make project available by attachment (zipped if necessary) or upload to fileshare site such as box.net and post link to file? Either way, remove confidential data, run Compact & Repair first.

    A form/subform arrangement would certainly work.

    What is nature of the relationship - if there is a record in table 1 will there always be related record in table 2?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    ETCallHome is offline Advanced Beginner
    Windows 7 64bit Access 2007
    Join Date
    Mar 2011
    Location
    Limpopo, South Africa
    Posts
    48
    Hi June,

    Sorry for replying so late, but I think I found the problem. When I created the 1 to 1 relationship, I assumed that Tbl1 was the parent and Tbl2 was the child, it appears that Access made Tbl2 the parent and Tbl1 the child. When I enter the data in fldA of Tbl2, it allowed me to save the record, however only the record on Tbl2 was saved, becase Tbl1 had a second fld as a primary key and since this value was null, it did not save the Tbl1 record.

    I am busy making changes to my code to see that the function works and will keep you updated.

    Thanks a mill

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

Similar Threads

  1. Enter Data into a Junction Table
    By darkwan75 in forum Database Design
    Replies: 3
    Last Post: 04-13-2011, 08:55 PM
  2. Using composite keys to enter data in a form
    By kymmyg in forum Database Design
    Replies: 2
    Last Post: 09-08-2010, 01:20 PM
  3. How do I enter data automatically?
    By ffurqana in forum Access
    Replies: 0
    Last Post: 07-08-2010, 07:47 PM
  4. Adding a table cannot enter data
    By tak4 in forum Queries
    Replies: 0
    Last Post: 02-03-2009, 10:04 AM
  5. can't enter data in some form fields
    By ashiers in forum Forms
    Replies: 1
    Last Post: 09-18-2008, 12:37 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