For simplicity, I have two tables (e.g. tblCustomer and tblOrders). Say tblCustomer primary key is an autoIncrement field (CustID) and tblOrders related field is CustID.
If I want to create a new order for a new customer, I first need to create a new customer, retrieve the new CustID, and then make an entry into tblOrders. I know how to write an append query (INSERT INTO ...) but how do I retrieve the last new CustID I created to use in the append query for tblOrders?
If I was using DAO, I could write something like:
How do you do the equivalent with ADO?
Thanks,
Rewdee
If I want to create a new order for a new customer, I first need to create a new customer, retrieve the new CustID, and then make an entry into tblOrders. I know how to write an append query (INSERT INTO ...) but how do I retrieve the last new CustID I created to use in the append query for tblOrders?
If I was using DAO, I could write something like:
Code:
Dim lngCustID as Long
With currentdb.OpenRecordset("tblCustomers")
.AddNew
!Name="some Customer
blah, blah
.Update
.move 0, .LastModified
lngCustID=!CustID
end With
With currentdb.OpenRecordset("tblOrders")
.AddNew
!CustID=lngCustID
blah, blah
.Update
End With
How do you do the equivalent with ADO?
Thanks,
Rewdee