Edgard
10-13-2004, 06:13 AM
Hi there!
My apologies if this question is one I should have found an answer to on the web or through any type of FAQ: I did spend quite some hours trying to figure this one but failed... :o
I'm working on what admittingly is my very first VB 6.0/Access 2000 project. In Access I've set up a number of tables, including (1:1;1:n;n:m) relationships through Autonumber-based ID fields.
I'm now at the point where I would like to add new records to these tables using ADO. And this is where I get puzzled... How do I achieve this from a general point of view? I know about AddNew, but none of the examples I found will demonstrate targeting multiple tables...
Personally what I think I need to do is:
Add a record to the main table using AddNew
Retrieve the (Autonumber) Primary Key using a seperate query
Add a record to one of the depending tables, using the Primary Key value retrieved in the previous step as the Foreign Key...
Could someone confirm whether this is indeed the approach to take? Is there maybe a SQL-based alternative that's more efficient or preferable for any other reason?
As you may guess, any suggestion is more than welcome!
Thank you in advance!
Cheers, Edgard
My apologies if this question is one I should have found an answer to on the web or through any type of FAQ: I did spend quite some hours trying to figure this one but failed... :o
I'm working on what admittingly is my very first VB 6.0/Access 2000 project. In Access I've set up a number of tables, including (1:1;1:n;n:m) relationships through Autonumber-based ID fields.
I'm now at the point where I would like to add new records to these tables using ADO. And this is where I get puzzled... How do I achieve this from a general point of view? I know about AddNew, but none of the examples I found will demonstrate targeting multiple tables...
Personally what I think I need to do is:
Add a record to the main table using AddNew
Retrieve the (Autonumber) Primary Key using a seperate query
Add a record to one of the depending tables, using the Primary Key value retrieved in the previous step as the Foreign Key...
Could someone confirm whether this is indeed the approach to take? Is there maybe a SQL-based alternative that's more efficient or preferable for any other reason?
As you may guess, any suggestion is more than welcome!
Thank you in advance!
Cheers, Edgard