Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Multiuser / Networking / April 2005

Tip: Looking for answers? Try searching our database.

Please clarify...

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Richard - 27 Apr 2005 05:30 GMT
Hi,

I'm new to Access and was trying to find out how to retrieve the record
identity after an insert...

Some postings I read suggested using MAX() to retrieve the inserted record
id, but that's not reliable, because another user or session could have
inserted a record in the same table too...

Fo example, in MS SQL after an insert, there are 3 ways to retrieve the
newly generated identity of the inserted record:

1) IDENT_CURRENT - returns the most recently inserted record id in a table
regardless of which process or session inserted it.

2) @@IDENTITY - returns the most recently inserted record id in a table
regardless of which process inserted it, but inserted in the current session.

3) SCOPE_IDENTITY - returns the most recently inserted record id in a table
by the current process in the current session.

How can this be done in Access? Has Access an equivalent functionality for
each of these 3 SQL features?

Thank you very much in advance,

Rick
Alex Dybenko - 27 Apr 2005 11:53 GMT
actually answer depends on where is your data. if you data on SQL server -
you can use any way you mentioned. if your data in mdb file - then you can
use either Select @@IDENTITY or (if you use recordset to add record) use
bookmark property to come back to last modified record and read it
autonumber value

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

> Hi,
>
[quoted text clipped - 25 lines]
>
> Rick
Graham R Seach - 27 Apr 2005 16:44 GMT
Also if using a recordset, you can access the primary key before the Update
method is executed.

I didn't know that you could use @@IDENTITY against a Jet database. It's
obviously unreliable, but interesting to learn nonetheless.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
---------------------------

> actually answer depends on where is your data. if you data on SQL server -
> you can use any way you mentioned. if your data in mdb file - then you can
[quoted text clipped - 34 lines]
>>
>> Rick
Alex Dybenko - 27 Apr 2005 16:59 GMT
Hi Graham,

> I didn't know that you could use @@IDENTITY against a Jet database. It's
> obviously unreliable, but interesting to learn nonetheless.

AFAIR - this is a feature of Jet 4.0

Signature

Alex Dybenko (MVP)
http://Alex.Dybenko.com
http://www.PointLtd.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.