Squall_FF8 1 Posted Tuesday at 02:03 PM Hey guys, I wanted to do simple thing - use Aggregates. So following the help: procedure TForm.Button1Click(Sender: TObject); begin if Qry.Aggregates.Count = 0 then with Qry.Aggregates.Add do begin Expression := 'COUNT(Town)'; Active := True; Qry.AggregatesActive := true; end; end; Should be pretty simple, right? But I get error (on Activate := true): Do you know why? What I'm doing wrong? Share this post Link to post
Lajos Juhász 323 Posted Tuesday at 02:32 PM (edited) First of all do not use with it is always a bad idea. You are not setting the name property for the aggregate object. Edit. I have checked even the examples on docwiki are wrong. Edited Tuesday at 02:34 PM by Lajos Juhász 1 Share this post Link to post
Squall_FF8 1 Posted Tuesday at 03:23 PM 47 minutes ago, Lajos Juhász said: You are not setting the name property for the aggregate object. Thank you very much!!! Usually thigs like this have default name that is good enough (it works, the name = you dont use/dont care) 50 minutes ago, Lajos Juhász said: First of all do not use with it is always a bad idea. Are you talking for Aggregates in general, or my example of use? Share this post Link to post
Lajos Juhász 323 Posted Tuesday at 04:24 PM 54 minutes ago, Squall_FF8 said: Are you talking for Aggregates in general, or my example of use? in general, when using with you can never sure to which object you are assigning a value. It can work in one version of Delphi and break in the next one. You can always write: var a: TFDAggregate; begin if Qry.Aggregates.Count = 0 then begin a:=Qry.Aggregates.Add; a.Expression := 'COUNT(Town)'; a.Active := True; a.Name:='NoName'; Qry.AggregatesActive := true; end; end; Share this post Link to post