read autonumber / identity

T

Tom Jackson

I want to read the primekey in a table with autonumber primekey after
insert. The equivalent of select @@identity In T-SQL. Any ideas on how to do
it in an access 2002?

thanks

tom
 
A

Alex Dybenko

you can use same syntax:

Dim rst As DAO.Recordset
CurrentDb.Execute "insert into table1 (aa) Values ('1')"
Set rst = CurrentDb.OpenRecordset("select @@identity")
Debug.Print rst.Fields(0)
 
Top