Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
4.73 Mб

GroupOptions TopNGroups property, Page 374

GroupOptions TopNOptions property, Page 374

GroupOptions TopNSortField property, Page 375

GroupOptions Methods

GroupOptions Add method, Page 376

GroupOptions Clear method, Page 377

GroupOptions CopyFrom method, Page 378

GroupOptions Count method, Page 378

GroupOptions Create method, Page 379

GroupOptions Delete method, Page 379

GroupOptions Destroy method, Page 379

GroupOptions Retrieve method, Page 380

GroupOptions Send method, Page 381



property GroupSelection: TCrpeGroupSelectionFormula;


TCrpeGroupSelectionFormula = class(TPersistent)


The GroupSelection object deals with the Group Selection Formula of a Report. It's main properties and methods are:

The Formula property holds the text of the Group Selection Formula.

The Replace property is a Boolean property that specifies if the text in the Formula property will replace the Group Selection that is already in the Report, or whether it will be ANDed on to the end of it.

The Retrieve method will fetch the Group Selection Formula that is currently in the Report, and place it in the Formula property.

The Check method can be used to determine whether the Formula syntax is correct.

VCL Reference


GroupSelection Example

This code sample passes a new Group Selection formula into the Report, replacing the one that was currently there:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.GroupSelection.Formula.Assign('Sum({company.SALES}, {company.STATE}) > 30000.00');

Crpe1.GroupSelection.Replace := True; Crpe1.Execute;

Using Variables with GroupSelection Formula

Delphi variables can be used with the GroupSelection Formula if they are declared as string or converted to string (regardless of the actual data type) before being passed to Crystal Reports. Remember also, that string values require extra quotes for Crystal Reports, as well as the usual single quotes that Delphi requires. The following examples cover some of the ways in which variables can be used:

1.Passing Integer values from Edit boxes:


nStart : string; nEnd : string;


nStart := Edit1.Text; nEnd := Edit2.Text;

Crpe1.GroupSelection.Formula[0] := 'Maximum({company.SALES},{company.STATE}) >= ' + nStart + 'AND Maximum({company.SALES},{company.STATE}) <= ' + nEnd;

2.Passing Integer variables:


nSales : integer; begin

nSales := 12345; Crpe1.GroupSelection.Formula[0] :=

'Maximum({company.SALES},{company.STATE}) > ' + IntToStr(nSales);

3.Passing Date variables (Crystal Reports accepts dates only as a string data type in the Date(YYYY,MM,DD) format):


dStart : string; dEnd : string;


dStart := '1998,01,31'; dEnd := '1998,06,30';

Crpe1.GroupSelection.Formula[0] := 'Maximum({company.STARTDATE},{company.STATE}) in Date(' + dStart + ') to Date(' + dEnd + ')';

VCL Reference


4.Passing Date variables divided into Day, Month, Year:


dYear : string; dMonth : string; dDay : string;


dYear := '1998'; dMonth := '06'; dDay := '31';

Crpe1.GroupSelection.Formula[0] := 'Maximum({company.STARTDATE},{company.STATE}) = Date(' + dYear + ',' + dMonth + ',' + dDay + ')';

5.Passing Date variables entered in Edit boxes:


dYear : string; dMonth : string; dDay : string; dWhole : string;


dYear := Edit1.Text; dMonth := Edit2.Text; dDay := Edit3.Text;

dWhole := 'Date(' + dYear + ',' + dMonth + ',' + dDay + ')'; Crpe1.GroupSelection.Formula[0] :=

'Maximum({company.STARTDATE},{company.STATE}) = ' + dWhole;

GroupSelection Properties

GroupSelection Formula property, Page 381

GroupSelection Replace property, Page 382

GroupSelection Methods

GroupSelection Check method, Page 383

GroupSelection Clear method, Page 384

GroupSelection CopyFrom method, Page 385

GroupSelection Create method, Page 385

GroupSelection Destroy method, Page 386

GroupSelection Retrieve method, Page 386

GroupSelection Send method, Page 387

VCL Reference


Соседние файлы в папке crystal