Results 1 to 4 of 4
  1. #1
    Chrelske is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Apr 2016
    Posts
    2

    Copy parent and child tables into new records on them

    All in advance thank you for helping me.

    I have a project database in MS-Access 2013 64bits.
    Most of the time when i had a question i looked it up in several fora and there always was a solution for my problem.


    But this time I've looked everywhere but I have so far found no solution.

    So i hope that someone can help me out in this.

    In my project database, I have a form with several sub forms.
    Behind every form is a table. All tables have a one to many relationship.
    For each subform a have Letter signed to it.(just to make it clear which table in connected to which subform)
    And on the form i also put this letters to the specific subforms.

    Click image for larger version. 

Name:	Relaties van Verkoopbonnen.jpg 
Views:	8 
Size:	81.0 KB 
ID:	24225


    Click image for larger version. 

Name:	calculatie formulier.jpg 
Views:	8 
Size:	131.8 KB 
ID:	24224

    What I want to achieve now is that when I have select a record in Form A and then I click the copy button,
    all the records are copied from all the subforms in a new record in the same project.
    In other words, a new record must be added in Form A , with all the data that were also present in the old record,including all the records from the child table.

    I really don't know how to achieve this.
    I think the only way is to do this is with VBA.
    VBA is no problem, i have work with this several times(I mean, I have copied various codes used in the past.
    Personally I'm not a programmer but it does nevertheless always workt to use it in my database).

    So finally if there is anyone who can help me, then I will really appreciate.

    Best regards,
    Chris van der Haar(the Netherlands)

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you would build a macro with lots of queries.
    Q1 would copy the master record,
    then you must grab the NEW key value on this new record.
    Using this key, you would select the child records from the old key and post new records with the new key.
    etc
    etc.

  3. #3
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  4. #4
    Chrelske is offline Novice
    Windows 7 64bit Access 2013 64bit
    Join Date
    Apr 2016
    Posts
    2
    Hello ranman256,

    The problem is that i don't know how to make een query that holds for example 2 or 3 ID's for the new to make child records(who also each have 5 records)
    So i have to loop true several records in the master table to catch the id's. (which should then be placed in memory to use them later).
    That is exactly my problem, I am not able to know how to do that.
    Is it possible to maken a query that hold's 2 or 3 id's to use later on?

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

Similar Threads

  1. Replies: 7
    Last Post: 07-28-2015, 11:50 AM
  2. Replies: 5
    Last Post: 05-04-2015, 02:02 PM
  3. Parent Child records in reporting
    By Darlene in forum Reports
    Replies: 1
    Last Post: 03-22-2014, 06:49 PM
  4. No (+) for parent-child tables in linked database
    By Seamus59 in forum Import/Export Data
    Replies: 3
    Last Post: 11-18-2013, 11:39 AM
  5. Delete child records with parent record
    By jpkeller55 in forum Access
    Replies: 8
    Last Post: 09-07-2010, 08:52 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