This post, as is the question, is concerning a JET MDB.
You need to anyways use a server side cursor in most cases.
With ADO 2.1 and higher, using a server side cursor (and in some cases a Client side cursor for an ADO object written in code will work- but not with the ADO Data Control and a DataGrid), and a JET 4 mdb, (and Jet4 provider of course), the example shown by harebrain works just as accurate, or in-accurate, as would be with @@identity.
Both methods get the value of the identity column in the same manner, and it is stored in the same location - in a property the provider in the connection, which in this case the value is stored as a property by the local Jet Engine - which is residing of course on the [/b]client[/b].
It is the local JET Engine which handles this, well, even in a multi-user environment and using a server side cursor. Makes no difference which method is used.
This holds true for JET OLEDB and JET ODBC.
(Jet will handle this also well, in the same matter, when working with linked SQL Server tables, as it then uses a server side cursor.)
So, if it is possible to get clashes with the one method, it is also possible with the other and at the same risk.
The way that JET handles the Identity field value with a newly added record added via the recordset's AddNew method is, (surprise, surprise), by issuing, (in addition to an action insert query to insert the record), a SELECT @@Identity command after the insert, all wrapped in a transaction!
So, when you do this:
AddNew/UpdateBatch
JET does this:
INSERT INTO....
SELECT @@Identity
The same as you can do when running an action query.
You will however need to use @@Identity when working with action queries, such as inserting a record using INSERT INTO and then needing the newly inserted record's ID.
As far as the comment concerning using MAX:
the code above looks like that is not what is being done, but instead, seeing if the number actually exists after adding the record.