last insert id

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
 
D

Dirk Goldgar

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.
 
T

Toxalot

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top