Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ADO - Get New Record ID

Status
Not open for further replies.

ProjectExplorer

Programmer
Mar 22, 2002
95
GB
I am adding a new record to an Access table using a OleCommand and SQL string containing "INSERT INTO tblOrders etc...." The back end table contains a AutoNumber field to generate a unique Order ID ("OID")as soon as the new record details are inserted by the code.

My problem is that I need to get the new Order ID (OID) as soon as the record is added (inserted) into the table but I cannot see how I do this with ADO.

I used to do this in ACCESS DAO using:

With rstOrders
.AddNew
.Fields ("Packs") = Me.cboPacks ' i.e. number of packs
intOID = .Fields ("OID") ' GET THE NEW ORDER ID
.Update
.Close
End With

Basically you could grab the new Order ID (OID) as soon as the new record was created (because DAO remains connected to the database).

I am not not how I can recreate this with ADO or what approach to take to acheive it.

Any help much appreciated.

Thanks


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top