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