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

Auto Increment PKID from rs.addnew

Status
Not open for further replies.

SimonTheSponge

Programmer
Feb 12, 2001
74
GB
I have a couple of questions, firstly what is the concensus

on inserting records into a table, do people pass an string containing an insert command with a connection.execute method

or

use the rs.addnew, assign the fields rs!fld1 = "blah" etc and then do a rs.update

Secondly if I have an autoincrementfield how do I get the value back after adding. I found a thread that indicated that Jet 4.0 supports @@identity, but using a seperate "select @@idendity from table" seems a little inadequate.

After doing a rs.addnew and then and rs.update , I was expecting the the local rs!autoincrfield to contain the new value, but it contains 0. Of course on the database it has successfully added an incremented value

How do people generally cope with Autoincrfields or do they not use them ?




 
I don't use access much anymore. Hoever, for your first question, what is the best method to use to do an insert you will want to use the command object.

See FAQ709-1526
 
@@IDENTITY will return the last added autoincrement value on that specific connection

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top