>FUNCTION GetNumero >* Get the next id >* expC1 Name of the table in TABLE.DBF >PARAMETER tcTable >PRIVATE lnOldSel,lnNext >LOCAL lnCompteur >lnOldSel=SELECT() >SELECT TABLE >LOCATE FOR TABLE=tcTable >SET REPROCESS TO 2 This means it will try 2 times, not 2 seconds. to be seconds it must have a SECONDS clause. >FOR lnCompteur=1 TO 10 > IF RLOCK() > EXIT > ENDIF >NEXT Doesn't look ok to me. What happens if the RLOCK() fails all times? After all, it tries only 20 times. This is very fast and it will fail very easy. So, the REPLACE will fire the message you said. >REPLACE NUMERO WITH NUMERO+1 >UNLOCK >lnNext=NUMERO >SELECT(lnOldSel) >RETURN lnNext >Vlad