Results 1 to 3 of 3
  1. #1
    CarolR is offline Novice
    Windows 10 Access 2016
    Join Date
    Mar 2014
    Posts
    4

    Adding new records to 2 tables via one main form/subform

    Hi. I 'inherited' a large database (I did not design this DB) that was split into 2 separate tables (TBL1 and TBL2) based on a key field (fam_no) which is an" autonumber" field. (It was split because original table exceeded # of allowed columns.) The now 2 individual tables are linked by a created relationship on the fam_no field-with enforce referential integrity checked. (The fam_no is in both tables) TBL1 houses the family info (name, address, etc.) and TBL2 houses events and dates. The relationship between the 2 tables is ONE to ONE (not one to many). I need to create one form that will ADD RECORDS to both of these tables. I created a main form, with an embedded subform with the 'Link Master' and 'Link child' both set to fam_no.
    I can successfully view data in the form from both of these tables. However, when I try to add a new record I get the following message: YOU CANNOT ADD OR CHANGE A RECORD BECAUSE A RELATED RECORD IS REQUIRED IN TBL 2.
    Does anyone know what I'm doing wrong? Does it have something to do with the key field in both tables being the fam_no which is "autonumber"? When the original table was split into 2 separate tables, the autonumber (fam_no) was the only field that could be used to link the 2 new tables. ANY HELP WOULD BE SOOOOOO APPRECIATED! Thank You!

  2. #2
    Minty is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,005
    If you have set the relationship and enforced referential integrity , I think you have made it virtually impossible to add records, as you need a record in table 1 before you can insert a record in table 2, however you also need a record in table 2 before you can add one in table 1 etc. etc. Catch-22.

    Make the relationship 1 to Many, and it will probably work.

    And the autonumber in both won't work, that will have to simply be a number field in table 2
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,975
    Cannot link tables on autonumber fields. Even though 1-to-1 relationship, one table must assume the 'master' role and one the 'child'. One table must receive the fam_no value as foreign key in a number field. Can set this number field to not allow duplicates.

    I suspect data structure is not properly normalized.
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-07-2018, 04:38 PM
  2. Replies: 4
    Last Post: 01-18-2017, 12:41 PM
  3. Replies: 1
    Last Post: 07-10-2015, 06:38 PM
  4. Replies: 4
    Last Post: 03-14-2012, 10:08 AM
  5. Replies: 2
    Last Post: 12-07-2011, 02:51 AM

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