Link to home
Start Free TrialLog in
Avatar of wrussell051197
wrussell051197

asked on

Retrieving an autonumber field

How can I retrieve the autonumber field from a record I just added, I tried the following:

' created rs as a recordset and queried the database
rs.addnew
rs("field1") = "data"
rs("field2") = "data"
rs.update
id = rs("autonumfield")

but rs("autonumfield") does not return the value that was put into the field, however it does show up when I query the database.

Thanks for any help you can provide.
Avatar of DarrenJ
DarrenJ

Are you using Microsoft Access or SQL Server?
Avatar of wrussell051197

ASKER

Currently I'm using MS Access, but I may be switching over to SQL in the near future. SQL is SELECT @@IDENTITY isn't it? Or something similar if I remember rightly. Right now I just need the technique to get it from Access.
ASKER CERTIFIED SOLUTION
Avatar of DarrenJ
DarrenJ

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
That's it, thanks!