Results 1 to 2 of 2
  1. #1
    dougperk is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jun 2012
    Posts
    2

    Append Query with a foreign key

    I have 3 linked tables (SQL tables) and I want to use a single form to input data that will be used to populate the 3 tables. SQL will auto-number the PrimaryKey in each of the 3 tables, but I don't know how to construct the Append Query so that Tables 2 & 3 will get the foreignkey value to Table 1.

    Table1
    Patient_id (primarykey)
    First_Name
    Last_Name

    Table2
    Addr_Id (primarykey)
    Patient_id (foreignkey to Table1)
    Addr_1
    Addr_2
    ...etc

    Table3
    Insuance_id (primarykey)
    Patient_id (foreignkey to table1)
    Carrier_Name
    ...etc

    My input Form will contain all the fields necessary for the 3 tables. (NOTE: the form will NOT be providing the 3 primarykeys, as SQL assigns these.)
    I assume I will need 3 separate Append Queries.


    Writing the first query to populate Table1 is easy.
    How, though, do I write the Append Query for Table2, so that Table2.Patient_id will pull the value of the just created Table1.Patient_id ?

    I know the easiest approach would be to create a Main/Subforms setup to accomplish this. But with that I cannot figure out how to make Table 2 and Table 3 REQUIRED. (ie I do not want a Table1 entry to be created with a corresponding Table2 and Table 3 entry.)

    Thanks in advance
    Doug

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Why do you need APPEND?

    Are you using unbound forms?

    Have you tried form/subform arrangement?
    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: 10
    Last Post: 05-08-2012, 09:17 AM
  2. Replies: 2
    Last Post: 04-19-2012, 11:29 AM
  3. Replies: 3
    Last Post: 03-15-2012, 02:11 PM
  4. Replies: 1
    Last Post: 10-06-2011, 08:37 AM
  5. Replies: 7
    Last Post: 07-21-2011, 01:01 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