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

And there is a Selection Formula in the VCL that reads:

{company.SALES} = 100000

If Replace is True, the Selection Formula in the Report (when it is run) will read:

{company.SALES} = 100000

If Replace is False, the Selection Formula in the Report (when it is run) will read:

{company.STATE} = "WA" AND {company.SALES} = 100000

By default, Replace is set to True.

Example

The following example retrieves the current Group Selection Formula from the Report and adds an OR condition. It then sends the Formula back in, replacing the one that is currently there:

Crpe1.ReportName := 'C:\Company.rpt'; {Retrieve the GroupSelection} Crpe1.GroupSelection.Retrieve;

{Add an OR condition} Crpe1.GroupSelection.Formula.Add(' OR Maximum({company.BRANCHES},{company.STATE}) > 12');

{Replace the GroupSelection in the Report with the new one} Crpe1.GroupSelection.Replace := True;

{Check the GroupSelection before running Report} if Crpe1.GroupSelection.Check then

begin

Crpe1.Output := toWindow; Crpe1.Execute;

end;

GroupSelection Methods

GroupSelection Check method

Declaration

function Check: boolean;

Description

The Check method can be used to check the syntax of a GroupSelection Formula before running the Report. Check returns a boolean value:

True :GroupSelection Formula is good.

False :GroupSelection Formula has an error.

VCL Reference

383

Example

The following example retrieves the current Group Selection Formula from the Report and adds an OR condition. It then sends the Formula back in, checking for the proper syntax:

Crpe1.ReportName := 'C:\Company.rpt'; {Retrieve the GroupSelection} Crpe1.GroupSelection.Retrieve;

{Add an OR condition} Crpe1.GroupSelection.Formula.Add(' OR Maximum({company.BRANCHES},{company.STATE}) > 12');

{Replace the GroupSelection in the Report with the new one} Crpe1.GroupSelection.Replace := True;

{Check the GroupSelection before running Report} if Crpe1.GroupSelection.Check then

begin

Crpe1.Output := toWindow; Crpe1.Execute;

end;

GroupSelection Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the GroupSelection object. It clears the Formula property and sets the Replace property to True. It is called automatically if the Clear method is called for the main component, or if a new Report name is assigned to the ReportName property, but may be called in code as desired.

The Clear method is only applied to the GroupSelection object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the GroupSelection of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method.

Example

This code clears the GroupSelection for the main Report (assuming the default state of Subreports[0]):

Crpe1.GroupSelection.Clear;

This code clears the GroupSelection for all the Subreports:

for cnt := 1 to (Crpe1.Subreports.Count - 1) do begin

Crpe1.Subreports[cnt];

Crpe1.GroupSelection.Clear; end;

VCL Reference

384

GroupSelection CopyFrom method

Declaration

function CopyFrom(Source: TCrpeGroupSelectionFormula): boolean;

Description

The CopyFrom method copies the GroupSelection property values from another TCrpeGroupSelectionFormula object. It is similar to Delphi's Assign method. It is useful for transferring or temporary storage of values.

Example

The following example copies all the GroupSelection property values to a temporary TCrpeGroupSelectionFormula object:

var

tempGroupSelection : TCrpeGroupSelectionFormula; begin

tempGroupSelection := TCrpeGroupSelectionFormula.Create; tempGroupSelection.CopyFrom(Crpe1.GroupSelection); {...later, when finished with the temp object...} tempGroupSelection.Free;

HQG

GroupSelection Create method

Declaration

constructor Create;

Description

The Create method is used internally in the Crystal component to create the GroupSelection object, and does not need to be called in code.

VCL Reference

385

GroupSelection Destroy method

Declaration

destructor Destroy; override;

Description

The Destroy method is used internally in the Crystal component and does not need to be called in code.

GroupSelection Retrieve method

Declaration

function Retrieve: boolean;

Description

The Retrieve method obtains the Group Selection Formula from the Report and stores it in the Formula property of the GroupSelection object. If successful, the call returns True. Be aware that calling Retrieve will first cause the GroupSelection object to be cleared, so any current information stored in it will be removed and the Replace property will be set back to default.

NOTE: Since the GroupSelection object also applies to Subreports, the Retrieve method will obtain the GroupSelection for the Report (or Subreport) that the Subreports object index is currently pointing to. If you want to obtain the GroupSelection information for the main Report and all of the Subreports, you will have to step through the Subreports object and call Retrieve for each item. The VCL will store separate GroupSelection information for each Subreport (see Example).

Example

The following code illustrates the use of the Retrieve method for the main Report:

Crpe1.ReportName := 'C:\Company.rpt';

Crpe1.GroupSelection.Retrieve;

The following code illustrates the use of the Retrieve method for the main Report and any Subreports:

var

cnt: integer; begin

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.Subreports.Retrieve;

VCL Reference

386

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