if file('test_sqlsum.dbf') // drop table test_sqlsum endif if not file('test_sqlsum.dbf') create table test_sqlsum (id autoinc,talname character(15),item character(15),; qty numeric(10,2),cost numeric(10,2),sell numeric(10,2)) insert into test_sqlsum (talname,item,qty,cost,sell) values ("Charlie","a",3.00,10.00,15.00) insert into test_sqlsum (talname,item,qty,cost,sell) values ("Charlie","b",2.00,2.00,4.00) insert into test_sqlsum (talname,item,qty,cost,sell) values ("Baker","a",2.00,10.00,15.00) insert into test_sqlsum (talname,item,qty,cost,sell) values ("Abel","a",1.00,10.00,15.00) insert into test_sqlsum (talname,item,qty,cost,sell) values ("Delta","b",5.00,2.00,4.00) insert into test_sqlsum (talname,item,qty,cost,sell) values ("Abel","b",7.00,2.00,4.00) endif ** END HEADER -- do not remove this line // // Generated on 2018-06-13 // parameter bModal local f f = new test_sqlsumForm() if (bModal) f.mdi = false // ensure not MDI f.readModal() else f.open() endif class test_sqlsumForm of FORM with (this) height = 31.6818 left = 23.0 top = 1.5909 width = 138.2857 text = "" endwith this.TEST_SQLSUM2 = new QUERY(this) with (this.TEST_SQLSUM2) left = 14.0 width = 10.0 height = 1.0 sql = 'select distinct talname from "test_sqlsum.DBF"' active = true endwith this.TEST_SQLSUM3 = new QUERY(this) with (this.TEST_SQLSUM3) left = 25.0 width = 10.0 height = 1.0 sql = 'select talname,sum(qty) as nCount,sum(qty*cost) as totcost,sum(qty*sell) as totsell from "test_sqlsum.DBF" group by talname' active = true endwith this.TEST_SQLSUM1 = new QUERY(this) with (this.TEST_SQLSUM1) left = 3.0 width = 10.0 height = 1.0 sql = 'select * from "test_sqlsum.DBF"' active = true endwith this.GRID1 = new GRID(this) with (this.GRID1) dataLink = form.test_sqlsum1.rowset height = 6.0 left = 4.0 top = 3.0 width = 118.0 endwith this.GRID2 = new GRID(this) with (this.GRID2) dataLink = form.test_sqlsum2.rowset height = 5.5 left = 3.0 top = 11.5 width = 27.0 endwith this.GRID3 = new GRID(this) with (this.GRID3) dataLink = form.test_sqlsum3.rowset allowEditing = false height = 5.5 left = 3.0 top = 19.0 width = 121.0 endwith this.PUSHBUTTON1 = new PUSHBUTTON(this) with (this.PUSHBUTTON1) onClick = class::PUSHBUTTON1_ONCLICK height = 1.0909 left = 12.0 top = 26.0 width = 15.2857 text = "Get totals" endwith this.ENTRYFIELD1 = new ENTRYFIELD(this) with (this.ENTRYFIELD1) dataLink = form.test_sqlsum3.rowset.fields["talname"] height = 1.0 left = 11.0 top = 28.5 width = 8.0 endwith this.ENTRYFIELD2 = new ENTRYFIELD(this) with (this.ENTRYFIELD2) dataLink = form.test_sqlsum3.rowset.fields["ncount"] height = 1.0 left = 40.0 top = 28.5 width = 8.0 endwith this.ENTRYFIELD3 = new ENTRYFIELD(this) with (this.ENTRYFIELD3) dataLink = form.test_sqlsum3.rowset.fields["totcost"] height = 1.0 left = 69.0 top = 28.5 width = 8.0 endwith this.ENTRYFIELD4 = new ENTRYFIELD(this) with (this.ENTRYFIELD4) dataLink = form.test_sqlsum3.rowset.fields["totsell"] height = 1.0 left = 97.0 top = 28.5 width = 8.0 endwith this.TEXTLABEL1 = new TEXTLABEL(this) with (this.TEXTLABEL1) height = 1.0 left = 5.0 top = 1.5 width = 12.0 text = "Data table" endwith this.TEXTLABEL2 = new TEXTLABEL(this) with (this.TEXTLABEL2) height = 1.0 left = 3.0 top = 17.5 width = 14.0 text = "Summed values" endwith this.TEXTLABEL3 = new TEXTLABEL(this) with (this.TEXTLABEL3) height = 1.0 left = 4.0 top = 10.0 width = 12.0 text = "Names" endwith this.TEXTLABEL4 = new TEXTLABEL(this) with (this.TEXTLABEL4) height = 1.0 left = 39.0 top = 13.5 width = 25.0 text = "Select name" endwith this.rowset = this.test_sqlsum1.rowset function PUSHBUTTON1_onClick() form.test_sqlsum3.rowset.applyLocate([talname = ']+form.test_sqlsum2.rowset.fields['talname'].value+[']) // form.rowset.applyLocate( "CITY = '" + form.cityText.value + "'" ) return endclass