Thanks Michel - Just what I was looking for.
Gaylen
>>I need to generate a sequential number to add to applications as they are entered into a table. The applications will be keyed by a number of key punchers and I need a method to create the sequential number and populate the records as they are added to the table. Waiting for VFP8 is not an option although I understand it will do it natively.
>
>We have this approach to query our Table.dbf table for the next ID:
>
>
>* Get the next id
>* expC1 Name of the table in TABLE.DBF
>FUNCTION GetNumero
>PARAMETER tcTable
>LOCAL lnOldSel,lnCompteur
>lnOldSel=SELECT()
>lnCompteur=0
>SELECT TABLE
>SEEK UPPER(PADR(tcTable,8,' ')) ORDER TAG TABLE
>DO WHILE (NOT RLOCK()) AND (INKEY(0.1)=0) AND lnCompteur<=25
> lnCompteur=lnCompteur+1
>ENDDO
>REPLACE NUMERO WITH NUMERO+1
>UNLOCK
>SELECT(lnOldSel)
>RETURN TABLE.NUMERO
>