Results 1 to 5 of 5
  1. #1
    jaworski_m is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    25

    Importing data from database where tables are related - PK autonumber

    Hello,
    I would like to import data from two tables, which are 1-many related, from database.A to database.B.
    Primary Key is an autonumber field.


    Is there a way to do it to keep referential integrity between the tables?

    Thank you for hints.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Do you want all the records or is this a selective import?

    Why is this necessary? This will be a repetitive procedure, meaning you have to do this on a regular basis?
    Last edited by June7; 01-11-2015 at 03:04 AM.
    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
    jaworski_m is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    25
    Do you want all the records or is this a selective import?
    All records are to be imported.

    Why is this necessary? This will be a repetitive procedure, meaning you have to do this on a regular basis?
    I want to combine a few (~8) databases of the same structure into one.
    This is a task that will be done only once, so I can do it manually. My only concern is the autonumber field used for PK.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,921
    Can be done.

    Do the 1-side tables in each of the dbs currently use autonumber PK?

    Import the records so that the original PK/FK data are saved into a regular number type field in both tables. The records of the 1-side will receive new PK. After each import, populate a field in each table with a source identifier (A, B, C, D, E, F, G, H) for that set of new records. Build a query that joins the tables on the old PK/FK values and the source identifier and update the new PK into another field of the many-side table.

    Once everything looks good, can delete the old PK/FK fields as well as the Source fields.
    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
    jaworski_m is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2015
    Posts
    25
    Works.
    Thank you.

    Small remark. During this operation "Enforce referencial integrity" must be (at least temporary) disabled, because it is not possible to append records to the table on many side if there is no PK the appended records can refere to.

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

Similar Threads

  1. Replies: 3
    Last Post: 11-15-2013, 03:15 PM
  2. Replies: 14
    Last Post: 03-22-2013, 06:35 PM
  3. Replies: 5
    Last Post: 12-14-2012, 04:21 PM
  4. Replies: 10
    Last Post: 07-18-2012, 03:42 PM
  5. Replies: 1
    Last Post: 07-16-2012, 02:10 PM

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