Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 4 of 4 total
Thread EDBQuery Aggregate field
Sat, Jan 17 2015 2:24 AMPermanent Link

Trinione

Hi:
I have a datagrid that has an EDBQuery as its datasource. How can I get a column total to display in a label field elsewhere on the form?

I have created a TAggregate field named 'totalCost' using the Field Editor and have set the Expression property to 'SUM (items)', and set the Active and Visible properties to 'True'.

However, when I access the field, it is blank. Frown

>> ShowMessage(EDBQueryCurrentDebts.FieldByName('totalItems').AsString);
Sat, Jan 17 2015 3:32 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Trinione


I have never used a TAggregateField and googling I suspect it is only available for ClientDataSet



Roy Lambert
Mon, Jan 19 2015 6:20 PMPermanent Link

Adam Brett

Orixa Systems

Trinione

I have not used the Aggregate field either, at least not for about 14 years, and I can't remember the full details, but I know that it cannot be used for the purpose you describe.

Instead I think the easiest thing is to add a second query to your application and use a second query statement to generate the sum or sums required.

You will need some code to synchronize the opening of the 2 queries, and perhaps passing in parameters to keep the values identical ... but that is not too hard to do.

I can also suggest that there are a number of Grid components (Dev Ex dxGrid and others) which have built in code for generation of SUMs and other aggregates. You might find that is the easiest solution to the problem, although these components often cost a bit of money.
Tue, Jan 20 2015 3:43 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Adam


> although these components often cost a bit of money.

Now that you're a lottery winner where do I send the begging letters to? Or did you just forget how to spell LOT?

Roy
Image