Autonumber -- How to access next one?

N

Nikos Antoniou

Hello ng,

I would like to ask if there is a way to access the next Autonumber assigned
by MSAccess on a record. This is can be done in SQL Server with the variable
@@identity, I hope there is a way to "know" the next Autonumber value at the
time of a new record addition. Right now, I do it by starting a Transaction
via ADO and after the addition, I get the max Key from that table.
Excuse me if this question has already been answered.

Thanks in advance,

Nikos Antoniou

PS. I talking about incremental Autonumber.
 
M

[MVP] S. Clark

It is not possible to return the Autonumber value assigned from an Append
query.

With code, you can create the new record and return the new value.

Function AddRecord()

..AddNew
lngNewID = !ID
..Update

AddRecord = lngNewID

End Function

--
HTH,

Steve Clark, Access MVP
FMS, Inc.
Professional Solutions Group
http://www.FMSInc.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Is your Access database too slow?
Are you ready to upgrade to SQL Server?
Contact us for optimization and/or upsizing!
http://www.FMSInc.com/consulting
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
 

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