>Select CASH_B >Scan > cr1 = 0 > acc_code = "" > > Scatter Memvar > Select VOUCHERS *There's no reason to do a LOCATE FOR followed by a SCAN WHILE. *Just do SCAN FOR. *You're confusing this with a SEEK and then a SCAN WHILE. *SEEK can be much faster than a LOCATE > *Locate For Date = m.date And vou_no = m.balance; > And vou_type = 'JV' > *SCAN WHILE Date = m.date And vou_no = m.balance; > And vou_type = 'JV' SCAN FOR Date = m.date And vou_no = m.balance; And vou_type = 'JV' > If m.dr_amount>0 AND cr_amount > cr1 > cr1 = cr_amount > ac1 = acccode > ENDIF > ENDSCAN > > Select CASH_B > Replace ACC_CODE With ac1 >endscan >>