SELECT Mstr.nam, Mstr.bank, Mstr.sheqno, Mstr.dat, Mstr.tra, S1.amount FROM Mstr ; inner join (SELECT nam,amount,bank,sheqno,dat,tra, SUM(amount) AS bill_total FROM Mstr ; on Mstr.Nam = S1.Nam and Mstr.Bank = S1.Bank and Mstr.SheqNo = S1.SheqNo ; and Mstr.dat = S1.dat ; ORDER BY Mstr.sheqno INTO CURSOR qTmpthanks
>>> >>thisform.olecontrol1.Visible=.t. >> >>thisform.grid1.Visible=.f. >> >>LOCAL ldStart >>ldStart = thisform.text1.value > >=messagebox(vartype(m.ldStart)) && I want to check, if this is a date type > >>************************************* > >select Mstr && Locate needs to select a table first, seek doesn't > >locate for dat = m.ldStart >> IF FOUND() >>********************************** >* Here we need to change ENGINEBEHAVAIOR if we want to select memo, though we can change our select instead > > SELECT Mstr.nam, Mstr.bank, Mstr.sheqno, Mstr.dat, Mstr.tra, S1.bill_total FROM Mstr ; > inner join (SELECT nam,amount,bank,sheqno,dat,tra, SUM(amount) AS bill_total FROM Mstr ; >>WHERE dat = m.ldStart ; >>GROUP BY nam,bank,sheqno, dat) S1 ; && Obviously we don't want to group by Amount > on Mstr.Name = S1.Name and Mstr.Bank = S1.Bank and Mstr.ShegNo = S1.ShegNo ; > and Mstr.dat = S1.dat ; > ORDER BY Mstr.sheqno INTO CURSOR qTmp > >&& Hmmm, why did we do locate at all? - why we can not always select first and choose various paths depending on _tally ? > >** BTW, above assumes we may have multiple same dates for the same Nam, Bank and ShegNo but different amounts > >>SELECT csrBillTotals >>ZAP >>APPEND FROM DBF( [qTmp] ) >>go top >> > >** Don't need to run the same code twice > >*> SELECT csrBillTotals >*>ZAP >*>APPEND FROM DBF( [qTmp] ) >>Thisform.refresh() > >* Since we're using "safe select" technique the rest of the code is not needed >* and needs to be commented out > >> * thisform.grid1.column1.header1.forecolor='255,255,0' >> thisform.grid1.column1.header1.caption="ÊÇÑíÎ ÇáÔíß" >> thisform.grid1.column1.header1.fontsize=12 >> thisform.grid1.column1.WIDTH=88 >> thisform.grid1.column1.header1.fontbold=.t. >> thisform.grid1.column1.Alignment = 2 >> backcolor="128,128,255" >> >> thisform.grid1.column2.header1.caption="ÑÞã ÇáÔíß" >> thisform.grid1.column2.header1.fontsize=12 >> thisform.grid1.column2.WIDTH=88 >> thisform.grid1.column2.header1.fontbold=.t. >> thisform.grid1.column2.Alignment = 2 >> backcolor="128,128,255" >> >> >> >> thisform.grid1.column3.header1.caption="ãÓÍæÈ Úáì" >> thisform.grid1.column3.header1.fontsize=12 >> thisform.grid1.column3.WIDTH=88 >> thisform.grid1.column3.header1.fontbold=.t. >> thisform.grid1.column3.Alignment = 2 >> backcolor="128,128,255" >> >> thisform.grid1.column4.header1.caption="ÞíãÉ ÇáÔíß" >> thisform.grid1.column4.header1.fontsize=12 >> thisform.grid1.column4.WIDTH=88 >> thisform.grid1.column4.header1.fontbold=.t. >> thisform.grid1.column4.Alignment = 2 >> backcolor="128,128,255" >> >> thisform.grid1.column5.header1.caption="ÇÓã ÇáãÓÊÝíÏ" >> thisform.grid1.column5.header1.fontsize=12 >> thisform.grid1.column5.WIDTH=120 >> thisform.grid1.column5.header1.fontbold=.t. >> thisform.grid1.column5.Alignment = 2 >> backcolor="128,128,255" >> else >> thisform.grid1.Visible=.f. >> endif >>