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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Table ID

Status
Not open for further replies.

CookieNZ

MIS
Apr 22, 2002
48
NZ
When connecting to an Access 2000 db using the oledbadapter, is it possible to read the ID of the last record in the database.

What I trying to do is use a sql script to insert a new record, but can not insert since I do not know the ID to insert the new record to.
 
Autonumber fields in MSAccess are assigned after the record is inserted, so there's no way to know what the ID will be. Try asking this question in the Access forum.

Chip H.
 
Can't you do something like object.MoveLast?

Larsson
 
Larsson -

Not really, since if it's a multi-user database, someone could have clicked their "Save" button immediately after you, and you'd end up with their Identity (autonumber) value. If you use ADO, it stores the last identity value on a per-connection basis. You can retrieve it with a simple "SELECT @@IDENTITY" query. Unfortunately, MS-Access doesn't offer this feature.

As far as I'm concerned, there is no reason to use MS-Access for new development, since the MSDE (desktop edition of SQL Server) is available, and is much more powerful.

Chip H.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top