Home > Archive > Programming with dBASE > December 2005 > agsum() function









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author agsum() function
Moses Hanna

2005-12-09, 7:23 am

Hi,
I have two numeric columns in a detailband.
I summed the columns with the agsum() function in the footerband
I want to put a 3rd field to contain the balance of the two columns totals
sum of column1 - sum of the column2.
any assistance how to code it?
Thank
Moses


Frank J. Polan

2005-12-09, 9:23 am

Moses

There's probably other ways , but here's one
Save the following & run from the navigator. Then check the functions
form_render, function DETAILBAND_onRender,
function
FOOTERBAND_preRender

to see how it was coded

HTH

Frank Polan


On Fri, 9 Dec 2005 23:23:05 +1100, "Moses Hanna"
<mosesjhanna@hotmail.com> wrote:

>
>Hi,
>I have two numeric columns in a detailband.
>I summed the columns with the agsum() function in the footerband
>I want to put a 3rd field to contain the balance of the two columns totals
>sum of column1 - sum of the column2.
>any assistance how to code it?
>Thank
>Moses
>
>

/*------------------------------------------------------- */
/* use this to create tables for turnkey */
/////////////// test.wfm ////////////////
close databases
close all
clear all
release all
clear memory
clear program
set proc to
//

if file('testagsum.dbf')
drop table 'testagsum.dbf'
endif
create table 'testagsum.dbf' ( ;
field1 char (10), ;
field2 numeric (6), ;
field3 numeric (6), ;
field4 char (10) ;
)

insert into testagsum (field1, field2, field3, field4) values
('abc',1,2, 'def')
insert into testagsum (field1, field2, field3, field4) values
('ghi',3,4, 'jkl')
insert into testagsum (field1, field2, field3, field4) values
('mno',5,6, 'pqr')


** END HEADER -- do not remove this line
//
// Generated on 12/09/2005
//
local r
r = new mosesReport()
r.render()

class mosesReport of REPORT
with (this)
render = class::FORM_RENDER
metric = 3 // Inches
autoSort = false
endwith

this.QUERY1 = new QUERY()
this.QUERY1.parent = this
with (this.QUERY1)
left = 2.1667
top = 0.3542
sql = "select * from testagsum"
active = true
endwith

with (this.printer)
duplex = 1 // None
orientation = 1 // Portrait
paperSource = 7
paperSize = 1
resolution = 0 // Default
color = 2 // Color
trueTypeFonts = 0 // Default
endwith

this.PAGETEMPLATE1 = new PAGETEMPLATE(this)
with (this.PAGETEMPLATE1)
height = 11.0
width = 8.5
marginTop = 0.75
marginLeft = 0.75
marginBottom = 0.75
marginRight = 0.75
gridLineWidth = 0
endwith

this.PAGETEMPLATE1.STREAMFRAME1 = new
STREAMFRAME(this.PAGETEMPLATE1)
with (this.PAGETEMPLATE1.STREAMFRAME1)
height = 8.0521
left = 0.25
top = 0.9479
width = 6.5
form.STREAMFRAME1 = form.pagetemplate1.streamframe1
endwith

this.STREAMSOURCE1 = new STREAMSOURCE(this)
with (this.STREAMSOURCE1.detailBand)
onRender = class::DETAILBAND_ON
RENDER
height = 0.1736
endwith

this.STREAMSOURCE1.detailBand.TITLETEXTFIELD1 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TITLETEXTFIELD1)
canRender = {||this.parent.firstOnFrame}
height = 0.2083
left = 0.125
top = 0.0243
width = 0.75
prefixEnable = false
suppressIfBlank = true
text = "<H3>Field1</H3>"
endwith

this.STREAMSOURCE1.detailBand.TEXTFIELD11 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTFIELD11)
height = 0.2035
left = 0.125
top = 0.2278
width = 0.75
variableHeight = true
prefixEnable = false
text = {||this.form.query1.rowset.fields["field1"].value}
endwith

this.STREAMSOURCE1.detailBand.TITLETEXTFIELD2 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TITLETEXTFIELD2)
canRender = {||this.parent.firstOnFrame}
height = 0.2083
left = 1.0313
top = 0.0451
width = 0.75
prefixEnable = false
alignHorizontal = 2 // Right
suppressIfBlank = true
text = {||this.form.query1.rowset.fields["field2"].value}
endwith

this.STREAMSOURCE1.detailBand.TEXTFIELD21 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTFIELD21)
height = 0.2035
left = 1.0313
top = 0.2486
width = 0.75
variableHeight = true
prefixEnable = false
alignHorizontal = 2 // Right
picture = "99999999999"
text = {||this.form.query1.rowset.fields["field2"].value}
endwith

this.STREAMSOURCE1.detailBand.TITLETEXTFIELD3 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TITLETEXTFIELD3)
canRender = {||this.parent.firstOnFrame}
height = 0.2083
left = 2.0625
top = 0.0347
width = 0.75
prefixEnable = false
alignHorizontal = 2 // Right
suppressIfBlank = true
text = "<H3>Field3</H3>"
endwith

this.STREAMSOURCE1.detailBand.TEXTFIELD31 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTFIELD31)
height = 0.2035
left = 2.0625
top = 0.2382
width = 0.75
variableHeight = true
prefixEnable = false
alignHorizontal = 2 // Right
picture = "99999999999"
text = {||this.form.query1.rowset.fields["field3"].value}
endwith

this.STREAMSOURCE1.detailBand.TITLETEXTFIELD4 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TITLETEXTFIELD4)
canRender = {||this.parent.firstOnFrame}
height = 0.2083
left = 3.1146
top = 0.0243
width = 0.75
prefixEnable = false
suppressIfBlank = true
text = "<H3>Field4</H3>"
endwith

this.STREAMSOURCE1.detailBand.TEXTFIELD41 = new
TEXT(this.STREAMSOURCE1.detailBand)
with (this.STREAMSOURCE1.detailBand.TEXTFIELD41)
height = 0.2035
left = 3.1146
top = 0.2278
width = 0.75
variableHeight = true
prefixEnable = false
text = {||this.form.query1.rowset.fields["field4"].value}
endwith

with (this.reportGroup.headerBand)
height = 0.1736
endwith

with (this.reportGroup.footerBand)
preRender = class::FOOTERBAND_PR
ERENDER
height = 0.1736
endwith

this.reportGroup.footerBand.TEXT2 = new
TEXT(this.reportGroup.footerBand)
with (this.reportGroup.footerBand.TEXT2)
height = 0.1708
left = 0.4688
top = 0.0104
width = 1.3889
variableHeight = true
prefixEnable = false
colorNormal = "b+"
alignHorizontal = 2 // Right
text =
{||this.parent.parent.agSum({||this.parent.STREAMSOURCE1.rowset.fields["Field2"].value})}
endwith

this.reportGroup.footerBand.TEXT4 = new
TEXT(this.reportGroup.footerBand)
with (this.reportGroup.footerBand.TEXT4)
height = 0.1708
left = 2.0417
top = 0.0208
width = 1.3889
variableHeight = true
prefixEnable = false
colorNormal = "b+"
alignHorizontal = 2 // Right
text =
{||this.parent.parent.agSum({||this.parent.STREAMSOURCE1.rowset.fields["Field3"].value})}
endwith

this.reportGroup.footerBand.TEXT1 = new
TEXT(this.reportGroup.footerBand)
with (this.reportGroup.footerBand.TEXT1)
height = 0.2083
left = 4.0104
top = 0.0625
width = 0.75
prefixEnable = false
text = "Text1"
endwith

this.firstPageTemplate = this.form.pagetemplate1
this.form.pagetemplate1.nextPageTemplate = this.form.pagetemplate1
this.form.pagetemplate1.streamframe1.streamSource =
this.form.streamsource1
this.form.streamsource1.rowset = this.form.query1.rowset

function DETAILBAND_onRender
this.parent.parent.col2pluscol3 +=
(this.parent.parent.query1.rowset.fields["field2"].value + ;

this.parent.parent.query1.rowset.fields["field3"].value)
return

function FOOTERBAND_preRender

this.text1.text = this.parent.parent.col2pluscol3
return

function form_render
this.col2pluscol3 = 0
return REPORT::render()

endclass


Sponsored Links





Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive | Programming forum archive

Copyright 2008 droptable.com