>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 >The only thing I would change at this point would be to elimate saving the barcno field to the memory variable. It is possible that two users could almost simultaneously enter into this code and cause it to fail....
IF USED("barcno") USE IN barcno ENDIF IF NOT USED("barcno") SELECT 0 USE barcno endif select barcno *nBarc=barcno.barcno *IF nBarc <= 0 IF barcno.barcno < = 0 MESSAGEBOX("This computer is not setup with barcode numbers","") RETURN ENDIF IF RLOCK('barcno') * replace barcno with nBarc+1 replace barcno with barcno + 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