last insert id

  • Thread starter Thread starter Toxalot
  • Start date Start date
T

Toxalot

I've searched on different terms already trying to get info on this
and I'm even more confused now than I was. I'm coming from the world
of MySQL which has LastInsertId which you can select in order to get
the number generated in the auto increment field from the last insert.

I'm working on an Access application and learning as I go. One of the
books I have is "Beginning Access 2003 VBA". An example uses Jet and
ADO and the Execute method of the Command object to do an insert. Then
it does a requery and moves to the beginning of the recordset. I don't
want to move to the beginning of the recordset. I want to go to the
record that was just inserted.

How can I know the autonumber of the record that was just inserted?

Jennifer
 
In
Toxalot said:
I've searched on different terms already trying to get info on this
and I'm even more confused now than I was. I'm coming from the world
of MySQL which has LastInsertId which you can select in order to get
the number generated in the auto increment field from the last insert.

I'm working on an Access application and learning as I go. One of the
books I have is "Beginning Access 2003 VBA". An example uses Jet and
ADO and the Execute method of the Command object to do an insert. Then
it does a requery and moves to the beginning of the recordset. I don't
want to move to the beginning of the recordset. I want to go to the
record that was just inserted.

How can I know the autonumber of the record that was just inserted?

Jennifer

If you're using ADO, you can open a recordset on the query

SELECT @@IDENTITY

using the same connection that you used to perform the insert, and read
the result.
 
How can I know the autonumber of the record that was just inserted?
If you're using ADO, you can open a recordset on the query

SELECT @@IDENTITY

using the same connection that you used to perform the insert, and read
the result.

Thanks. That did the trick.

Jennifer
 
Back
Top