It was wrong way to do it in VFP because locking a table blocks all other users from accessing it.
See
Record ID generator question Message #
611104>I use the follow code to get Unique Keys with VFP tables
>
>Local lgetUniqueKey
>Use myCounter
>IF Flock()
> Replace myCounter.counter With myCounter.counter+1
> lgetUniqueKey= myCounter.counter
> Flush In myCounter Force
> Unlock
>Endif
>
>Could you suggest some equivalent code if the MyCounter table is an MSSQL table?
>Please no autoinc field or global unique identifiers
--sb--