Insert records and then return ID to insert into sub table

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...
 
A

Allen Browne

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top