Hi Bernard, Why don't you instead of finding the last client number in CLIENT.DBF have a control table which would have the last client number. When you add a record to the CLIENT.DBF you can then lock the control, add 1 to the last client number, update the control table, store the last client number in a local variable, unlock the control table and then return the new client number. Try something like this: FUNCTION NextClient LOCAL nNextClientNo * ----- Assumes that controltable is already open SELECT controltable IF RLOCK() * ----- Controltable can be updated * Update the lastclientno in the control table REPLACE lastclientno ; WITH lastclientno + 1 nNextClientNo = lastclientno UNLOCK RETURN nNextClientNo ELSE * ----- Error Message for Controltable in use * and appropriate coding ENDIF Hope this helps, Gavin...>I have this table in a database.