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 / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

Get Record Just Appended

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
David M C - 14 Nov 2006 11:41 GMT
I append data (using DoCmd.RunSQL) to table JobsContWorks which has the
following fields:

ContValID (fk)
WorksID (pk - autonumber)
ParentID (for generating treeview)
OrderID (for generating treeview)
WorksName

This newly created record then needs adding to the Treeview. To do this, I
need to get the WorksID of the record just added. The only way I can think of
doing this is by finding the max WorksID. However, this is a multi-user
database so it is possible that two people may be adding records at the same
time. Potentially, the max WorksID will not be the record just added. Is
there any other way I can get the WorksID?

Just to clarify, my code goes:

DoCmd.RunSQL(strSQL) 'This appends the record using the generated SQL

<....... Some code using the WorksID of the record just added ...........>

Thanks,

Dave
Alex Dybenko - 14 Nov 2006 12:34 GMT
Hi,
if you are using Insert query - you can try to use @@identity:
http://support.microsoft.com/default.aspx/kb/232144

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

>I append data (using DoCmd.RunSQL) to table JobsContWorks which has the
> following fields:
[quoted text clipped - 23 lines]
>
> Dave
David M C - 14 Nov 2006 13:30 GMT
Thanks. Is this only available through ADO? The KB article isn't clear.

Dave

> Hi,
> if you are using Insert query - you can try to use @@identity:
[quoted text clipped - 27 lines]
> >
> > Dave
Alex Dybenko - 14 Nov 2006 16:44 GMT
Yes, I think only in ADO

Signature

Best regards,
___________
Alex Dybenko (MVP)
http://alexdyb.blogspot.com
http://www.PointLtd.com

> Thanks. Is this only available through ADO? The KB article isn't clear.
>
[quoted text clipped - 35 lines]
>> >
>> > Dave
 
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.