Retrieve autonumber

message from Efrain Flores on 28 May 2004
I would like to know how to retrieve the autonumber value assigned by access
2002 using vba. If you know any online resources wher I can find this or you
have any code that could help me, I will really appreciate it

Thank you
 
Joseph Meehan replied to Efrain Flores on 28 May 2004
Is there any problem with just referencing the field name of the table?
 
Allen Browne replied to Efrain Flores on 28 May 2004
You cannot retrieve the AutoNumber assigned by an append query statement,
but you can get the number if you append the value using DAO.

Dim rs As DAO.Recordset
Set rs= dbEngine(0)(0).OpenRecordset("MyTable", dbOpenDynaset, dbAppendOnly)
rs.AddNew
!SomeField = SomeValue
MsgBox "The number you will get is " & rs!ID
rs.Update
rs.Close
Set rs = Nothing
 

Archived message: Retrieve autonumber (MS Access Database)