Multiple table updates in DAO

M

Marcel K.

What is best way to add a new record that requires data to
be added to two tables - where one table is header
reference and the other is detail reference with FK
Relationship between two. I have DAO unbound form
recordset - .addnew works but not certain on best approach
to write the record becuase the foreignKey has to exist,
hence the header record needs to be updated first.

Thanks for your help,

Marcel K.
 
J

John Vinson

What is best way to add a new record that requires data to
be added to two tables - where one table is header
reference and the other is detail reference with FK
Relationship between two. I have DAO unbound form
recordset - .addnew works but not certain on best approach
to write the record becuase the foreignKey has to exist,
hence the header record needs to be updated first.

Well... yes. If you want to update two tables you need two updates;
and if you want to maintain relational integrity, you must do so in a
way which maintains relational integrity!

You can open a Transaction to do this, and ensure that both records
get committed or both get rolled back - but I'd really suggest just
opening two recordsets and doing two addnews.
 

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