Get ID of Last Inserted Record - Access DAO, ODBC, SQL Server 2008 Identity Field
问题 It's a very common question but I'm having trouble getting the ID of the last inserted record. I'm using DAO with ODBC linked tables to duplicate a record and it's child records. My tables are in SQL Server 2008 and have Identity fields for ID fields. Here's what I've tried so far. My first bit of code here results in error 3167, Record is Deleted. If I do a debug.Print the recordset actually contains 3 records. Dim r as DAO.Recordset, db as DAO.Database Set db = CurrentDb Set r = db