So, you need to know the new primary key value from the first append, in
order to use that value for the records in the 2nd append?
My preference is to use a Recordset to append the first level records,
because this makes it dead easy and reliable to get the value you just
added. You can then execute an append query statement to add the related
records.
Here's an example:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
It assumes you have selected the record in the form that you want to
duplicate, so it performs an AddNew and Update on the RecordsetClone of the
form.
If you don't have a form open, you will need to OpenRecordset on the desired
table. If that's new, here's how:
http://allenbrowne.com/func-DAO.html#DAORecordsetExample
Once you have the recordset open and the first record appended, read the new
value (as shown in the first example above.) You then have the number you
need to create the append query string to add the related records (again,
first example above.)
If there are further records to add to the original recordset, use MoveNext
to get to the next one inside a loop until you have them all.