MS Access w/ Insert + Select

P

Prince

Hi, I hava an Access table with the ID field being
autonumbered. Is is possible to write an INSERT query that
returns the ID that was generated for that particular
record? If so, how. From the readings I've been doing it
seems like SQL Server can do it but not ACCESS.

For example, the table name is Test with two fields.
ID ==> autonumber
Text ==> Text

What will the Query look like, if it is indeed possible.

thanks,
Prince
 
G

Guest

Yupp, after you have inserted a record, do a
"SELECT @@Identity" on the same connection.
 
P

Paul Clement

¤ Hi, I hava an Access table with the ID field being
¤ autonumbered. Is is possible to write an INSERT query that
¤ returns the ID that was generated for that particular
¤ record? If so, how. From the readings I've been doing it
¤ seems like SQL Server can do it but not ACCESS.
¤
¤ For example, the table name is Test with two fields.
¤ ID ==> autonumber
¤ Text ==> Text
¤
¤ What will the Query look like, if it is indeed possible.

See the following MS KB article:

HOW TO: Retrieve the Identity Value While Inserting Records into Access Database By Using Visual
Basic .NET
http://support.microsoft.com/default.aspx?scid=kb;en-us;815629


Paul ~~~ (e-mail address removed)
Microsoft MVP (Visual Basic)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top