>SELECT piorders >GO TOP >lnIIine = 1 >lnInstockRecno = RECNO('instock') >SCAN FOR piorders.nreqqty <> 0 > IF RLOCK('instock') > m.lnNewQty = IIF( instock.nordlev + nstock.nmaxlev > 0 , ; > instock.nqty - piorders.nreqqty , 0 ) > REPLACE ; > instock.nqty WITH m.lnNewQty ; > IN instock > IF instock.nqty = 0 AND (NOT instock.lreorder) > REPLACE ; > ldisflag WITH .T., ; > ldflag WITH .F. ; > IN instock > ENDIF > more code > lnIIine = lnIIine + 1 > UNLOCK IN instock > ENDIF >ENDSCAN >>
select instock goto recordInQuestion (OR do a SEEK) ? rlock('instock')Also, there is no need to lock the record every time through the scan, unless you have some deep, dark secrets in your 'more code' section. It appears that the entire scan updates the same record in the 'instock' table. You could lock the record at the beginning of the scan, and unlock it at the end.