Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Get unique id of record added

Status
Not open for further replies.

dan08

Technical User
Jan 7, 2013
51
US
I am trying to use vba to create an empty record in a table, so it will generate an id in the autonumber field. Then I want to get that number so I can use it to update a mapping table.
I have:
rst.addnew
rst.update

How can I get the unique id of the record that was created. I don't want to use dmax() because multiple people might be entering records simultaneously. I want a way to ensure that it is the id of the record that was just added.
Any Ideas?
 
What is displayed with this ?
rst.addnew
MsgBox "ID=" & rst!ID
rst.update
MsgBox "ID=" & rst!ID

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
The one before the update is Null and throws a Null error. The one after the update gives me the first ID in the table. I tried using a bookmark to go to the latest record and I got a window that said 'Record Deleted'. I am working with tables through and ODBC.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top