Link to home
Start Free TrialLog in
Avatar of shambalad
shambaladFlag for United States of America

asked on

Retrieve latest AutoNumber from table after DAO AddNew record

I am using DAO to write new records to a table where the primary key is an AutoNumber type field. After executing the .AddNew, .Update. I would like to retrieve the primary key for the record that was just added. What is the best way to do this? I am working in Access 2007.
Thanks,
Todd
SOLUTION
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of shambalad

ASKER

Both suggestions work, but I prefer getting the key while the record is being updated as in the second solution.
Thanks,
Todd
Todd,

  Just be aware that the second solution will not longer work if you move the data to SQL Server.

JimD.