index on bintoc(acct_Num)+bintoc({^2000-01-01}-Inv_Date) tag History local lnAcct_Num, lnPrice, lnDecrTotal, lnRecPrice lnPrice=60 lnAcctNum=1 lnDecrTotal= m.lnPrice set exact off seek bintoc(m.lnAcct_Num) scan while bintoc(acct_Num)+bintoc({^2000-01-01}-Inv_Date) = bintoc(m.lnAcct_Num) and m.lnDecrTotal>0 if m.lnDecrTotal>=m.lnPrice lnRecPrice=Price replace Price with 0, flag with 'Paid' m.lnDecrTotal=m.lnDecrTotal-m.lnRecPrice else && Decrease Total now is less than price replace price with Price-m.lnDecrTotal lnDecrTotal=0 && Go out endif endscanThis is off the top of my head and not tested...