This might not give you your latest id. It will only guarantee to give you the highest value of ourautonumberfieldname available in the table. And it might result in a table lock.
ujjwal soni wrote:Hi,
You can get that by firing select max(yourautonumberfieldname) from yourtable query.
After an insert a query like 'select @@identity' will return the last identity used by that connection. So even if another user makes an insert it won't affect the return variable. Plus it will be much faster than the other approach.
However, Microsoft Access 2000 or later does support the @@IDENTITY property to retrieve the value of an Autonumber field after an INSERT. Using the RowUpdated event, you can determine if an INSERT has occurred, retrieve the latest @@IDENTITY value, and place that in the identity column of the local table in the DataSet.