Hi Greg, thank you for your reply. I can not lock the whole table because it is used for other things. But I tried to lock the record and pass the next barcode number but on occasions, the number was duplicated if two operators where working on the system. When I closed and open the table, plus the rlock(), it seems to behave and I haven't seen any duplicates yet. Here is my modified code :
IF USED("barcno")
USE IN barcno
ENDIF
IF NOT USED("barcno")
SELECT 0
USE barcno
endif
select barcno
nBarc=barcno.barcno
IF nBarc <= 0
MESSAGEBOX("This computer is not setup with barcode numbers","")
RETURN
ENDIF
IF RLOCK('barcno')
replace barcno with nBarc+1
UNLOCK
else
MESSAGEBOX("The barcodes numbering file is in use, plese try again","")
RETURN
ENDIF
FLUSH in barcno force
IF USED("barcno")
USE IN barcno
ENDIF