Retrieve the Record ID Just Inserted

  • Thread starter Thread starter Samuel Shulman
  • Start date Start date
S

Samuel Shulman

Hi

Is there a way or retrieving the record ID of a record just added within the
same SQL statement or similar method

I am new to Access and in SQL Server one can use the @@Identity method

Thank you,
Samuel
 
Samuel Shulman said:
Hi

Is there a way or retrieving the record ID of a record just added
within the same SQL statement or similar method

I am new to Access and in SQL Server one can use the @@Identity
method

Thank you,
Samuel

If you use ADO to do your insert, you can keep using @@identity to
retrieve the last autonumber (identity), but you need separate
statements on the same connection (wouldn't you use scope_identity()
on SQL server?). Air code

cn.execute "INSERT INTO ....",, adCmdText+adExecuteNoRecords
set rs = cn.execute("SELECT @@Identity", , adCmdText)
debug.print rs.fields(0).value
 
Back
Top