0
votes

I am trying to feed the sum of a column (sum(#2 for all)) into an external SingleLineEdit control (on the same sheet as the DataWindow, but not in it) but I do not know how/where to implement the computation as sum() isn't a script "function".

So is it even possible to feed a DataWindow sum() out from the DataWindow itself and into a control? If so, how is it done? Will I have to manually calculate the sum with a loop?

Thanks for your help!

2

2 Answers

1
votes

You create a computed field in the datawindow with the sum(#2 for all) function. Give that field a name, like "mySum" or something. Place that computed field in one of the bands, like the header or footer.

Now, in the event/function script, do a dw.GetItemNumber( 1, "mySum" )

You can use any row number you want, but you're pretty certain to have a row 1 in your result set.

-Paul-

1
votes

In case you want to calculate without a computed field (dw.Describe('Evaluate(...)') is very versatile):

string expressionText, sumAsText, formattedSum

expressionText = 'sum(#2 for all)'
sumAsText= dw_data.Describe('Evaluate("' + expressionText + '", 0)')

// Formatting of your choice
sle_sum.Text = string(dec(sumAsText), "#,##0.00") 

/MicKr-