Creating new records in primary and foreign tables

H

hughess7

Hi all

I have some code which creates records in a table based on user data input
on a form in unbound text boxes. I now need to amend the routine to create
foreign records in a different table at the same time. The ItineraryID is an
autonumber, this is the link between the two tables - how would I be able to
find out what the number was of the record just created so I can add dates to
a foreign table for this Itinerary?

Hope that makes sense! Thanks in advance for any help.
Sue
 
A

Allen Browne

OpenRecordset() on the table, so you can AddNew (with Update) there. That
allows you to get the new autonumber value to use in the Append query
statement that creates the related records.

Here's an example:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
It assumes that the source record is the current record in your form, so it
uses the form's RecordsetClone instead of OpenRecordset. The logic is the
same though.
 
H

hughess7

Thanks works a treat :)

Sue


Allen Browne said:
OpenRecordset() on the table, so you can AddNew (with Update) there. That
allows you to get the new autonumber value to use in the Append query
statement that creates the related records.

Here's an example:
Duplicate the record in form and subform
at:
http://allenbrowne.com/ser-57.html
It assumes that the source record is the current record in your form, so it
uses the form's RecordsetClone instead of OpenRecordset. The logic is the
same though.
 

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