Results 1 to 5 of 5
  1. #1
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88

    Duplicate Master-Child records (versioning)

    Hi,


    I am trying to create a versioning function in Ms Access. That means that I have a bunch of related data that I would like to duplicate with a new version number, also the child records should be duplicated and linked to the newly duplicated items. I can't get my head around what the best approach would be. Do I need to do that in a loop that goes through each record, duplicates it, then uses the newly created PK (e.g. ID) to create the child records with that PK as FK (e.g. OrderID) ? Or is there a way to do that in one query?
    Thanks!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    What you describe sounds like an audit log.

    Review: http://allenbrowne.com/AppAudit.html

    Otherwise, why don't you just save copy of db every day?
    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
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    Thanks June but not really... Maybe by explaining how the data presents itself: There is an item which is the source of the main form. Then there is a subform (continuous form) with a Master/Child link with a bunch of sub-items. Then there are two other subforms (continuous forms) with parameters with a Master/Child link to the sub-item subform. So the table structure is One Item to Many sub-items. Then each one sub-items to many parameters1 and many parameters2. The user wants to be able to save/freeze a version (version 1) of all the items with all the related sub-items and parameters, and start with a copy of all that to make changes (version 2). Then he wants to be able to switch between version 1 and 2.
    So the idea is to keep the item as is but duplicate all the sub-items and parameters, and create the link (PK->FK) between the duplicated sub-items and the duplicated parameters.
    I know I could create a loop that goes through each records get the PK in a variable then run an append query on the child table with the saved PK variable as a FK... But could isn't there a cleverer way to do that all in one time. or in one query?
    Thank you.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    This has to be the most bizarre requirement I've ever read.

    How many 'versions' does user want - how many generations of versions? Just keep the original and then keep doing edits on the second? Don't care about keeping all the edits?

    So every time a new record is created, make a copy?

    Not sure what you mean by 'all in one time, or in one query'. If you need to grab the parent and all children (and grandchildren) records and copy them to respective tables, no, I don't think there is another way.
    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
    jerem is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Nov 2012
    Posts
    88
    Ok Thanks!

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

Similar Threads

  1. Replies: 1
    Last Post: 11-05-2014, 03:26 PM
  2. Replies: 22
    Last Post: 05-22-2014, 12:25 PM
  3. Filtering Master Records and Subform Child Records
    By Nerther in forum Programming
    Replies: 6
    Last Post: 10-01-2013, 05:24 PM
  4. Replies: 5
    Last Post: 03-23-2012, 11:40 AM
  5. Master/Child between Subforms
    By Pilotwings_64 in forum Forms
    Replies: 3
    Last Post: 08-22-2010, 01:45 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