Insert records and then return ID to insert into sub table

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi there...
Im looking to insert records into an Access table and then with the
resulting AutoInc ID instert further records into a child table. How do I
determine the ID of the Master tables to relate the child table?

<pseudocode>
SQL: INSERT INTO head_table (X, Y) VALUES (1, 2)
For i = 1 to 30
?? get result from inserted record ??
SQL: INSERT INTO line_table (HEADID, Z) VALUES (head_table.ID, 3)
Next
<end>

Something like that... cheers for any assistance...
 
See:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html

The code in the article shows how to choose a record to be duplicated,
create a new one and get the new key value, and then use that key value to
duplicate the child records in the related table also.
 
Back
Top