vCity = Thisform.ContCriteria.cboCity.DisplayValue Select simain.sino, ; simain.invdate, ; simain.pcode, ; simain.location, ; sisub.icode, ; sisub.qntymaj, ; sisub.qntymin, ; sisub.ratemaj, ; sisub.ratemin ; FROM simain, sisub ; WHERE simain.sino = sisub.sino AND ; simain.pcode # 'CP011' ; Into Cursor tmpsi ; ORDER By simain.sino Readwrite Alter Table tmpsi Add Column City c(52) Null INDEX on pcode+location TAG ploc ADDITIVE Select srmain.srno, ; srmain.srdate, ; srmain.pcode, ; srmain.location, ; srsub.icode, ; srsub.qntymaj, ; srsub.qntymin, ; srsub.ratemaj, ; srsub.ratemin ; FROM srmain, srsub ; WHERE srmain.srno = srsub.srno AND ; srmain.pcode # 'CP011' ; Into Cursor tmpsr ; ORDER By srmain.srno Readwrite Alter Table tmpsr Add Column City c(52) Null INDEX on pcode+location TAG ploc ADDITIVE Select tmpsi Go Top Scan While ! Eof() mpcode = pcode mloca = location Select location Set Order To ploc Seek mpcode+mloca In location mCity = City Select tmpsi Replace City With mCity Endscan Select tmpsr Go Top Scan While ! Eof() mpcode = pcode mloca = location Select location Set Order To ploc Seek mpcode+mloca In location mCity = City Select tmpsr Replace City With mCity Endscan Select Year(invdate) As Yur, ; cMONTH(invdate) As Munth, ; city as City,; SUM(qntymaj) As Cartons, ; SUM(qntymin) As Units, ; Sum(Iif(qntymin*ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As amount, ; Cast(0 As N(2,0)) As sno ; FROM tmpsi Where Year(invdate) Between myear1 And myear2 AND city = vCity ; GROUP By 1,2,3 ; ORDER By 1,2,3 Into Cursor siData Readwrite NOFILTER Index On Yur Tag Yur Select Year(srdate) As Yur, ; cMONTH(srdate) As Munth, ; city as City,; SUM(qntymaj) As Cartons, ; SUM(qntymin) As Units, ; Sum(Iif(qntymin*ratemin#0,qntymin*ratemin,qntymaj*ratemaj)) As amount, ; Cast(0 As N(2,0)) As sno ; FROM tmpsr Where Year(srdate) Between myear1 And myear2 AND city = vCity ; GROUP By 1,2,3 ; ORDER By 1,2,3 Into Cursor srData Readwrite NOFILTER Index On Yur Tag YurtmpSi = Sales table and similarly,