Select CASH_B Scan Scatter Memvar Select VOUCHERS Locate For Date = m.date And vou_no = m.balance; And vou_type = 'JV' If m.dr_amount>0 Select * From VOUCHERS Where Date = m.date And vou_no = m.balance; And vou_type ='JV' Into Cursor xxx Select Max(cr_amount) As cr_amount From xxx Into Cursor yyy Select yyy cr1=cr_amount Select ACC_CODE From VOUCHERS Where Date = m.date And vou_no = m.balance; And vou_type = 'JV' And cr_amount=m.cr1 Into Cursor zzz Select zzz ac1=ACC_CODE Select CASH_B Replace ACC_CODE With ac1 endif endscan