>lSuccess = .f.
>Do While Not lSuccess
> cSQL = "SELECT LastNumber FROM NumberTable WHERE cKey = 'TABLENAME'"
>
> SQLExec(nConn, cSQL)
>
> nLastNumber = SQLResult.LastNumber
> nNewId = nLastNumber + 1
>
> cSQL = "UPDATE NumberTable SET LastNumber = nNewID WHERE "+ ;
> "cKey='TABLENAME' and LastNumber = nLastNumber"
>
> lSuccess = ( SQLExec(nConn, cSQL) = 1 )
>EndDo
Thanks Bob, this seems to be a good solution. Not the most elegant way to obtain the goal, but I suppose there is no better way. Wouldn't have found it myself ....