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

Example

This example sets a ValueLimit for two ParamFields, a string and a datetime parameter:

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

{String Parameter: Entry Limit of 1 to 3 characters long} Crpe1.ParamFields[0].ShowDialog := True; Crpe1.ParamFields[0].ValueLimit := cTrue; Crpe1.ParamFields[0].ValueMin := '1'; Crpe1.ParamFields[0].ValueMax := '3';

{DateTime Parameter: Entry must be between min and max datetime} Crpe1.ParamFields[1].ShowDialog := True; Crpe1.ParamFields[1].ValueLimit := cTrue; Crpe1.ParamFields[1].ValueMin := '1998,01,01 12:00:00'; Crpe1.ParamFields[1].ValueMax := '1999,01,01 12:00:00'; Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields ValueMax property

Declaration

property ValueMax: string;

Description

The ValueLimit, ValueMin, and ValueMax properties work together. They provide a way of limiting the input in the Parameter prompt dialog edit field. ValueLimit simply determines whether the ValueMin and ValueMax properties are active or not. If ValueLimit is set to cFalse, the ValueMin and ValueMax properties will be ignored.

With string Parameters, ValueMin and ValueMax limit the length of the string that can be input. With other types, ValueMin and ValueMax contain the actual minimum and maximum values that can be entered.

NOTE:

Value limits, and the EditMask property are mutually exclusive. If an EditMask is defined, value limits will be ignored.

Value limits do not apply to Boolean Parameters.

VCL Reference

475

Example

This example sets a ValueLimit for two ParamFields, a string and a datetime parameter:

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

{String Parameter: Entry Limit of 1 to 3 characters long} Crpe1.ParamFields[0].ShowDialog := True; Crpe1.ParamFields[0].ValueLimit := cTrue; Crpe1.ParamFields[0].ValueMin := '1'; Crpe1.ParamFields[0].ValueMax := '3';

{DateTime Parameter: Entry must be between min and max datetime} Crpe1.ParamFields[1].ShowDialog := True; Crpe1.ParamFields[1].ValueLimit := cTrue; Crpe1.ParamFields[1].ValueMin := '1998,01,01 12:00:00'; Crpe1.ParamFields[1].ValueMax := '1999,01,01 12:00:00'; Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields ValueMin property

Declaration

property ValueMin: string;

Description

The ValueLimit, ValueMin, and ValueMax properties work together. They provide a way of limiting the input in the Parameter prompt dialog edit field. ValueLimit simply determines whether the ValueMin and ValueMax properties are active or not. If ValueLimit is set to cFalse, the ValueMin and ValueMax properties will be ignored.

With string Parameters, ValueMin and ValueMax limit the length of the string that can be input. With other types, ValueMin and ValueMax contain the actual minimum and maximum values that can be entered.

NOTE:

Value limits, and the EditMask property are mutually exclusive. If an EditMask is defined, value limits will be ignored.

Value limits do not apply to Boolean Parameters.

VCL Reference

476

Example

This example sets a ValueLimit for two ParamFields, a string and a datetime parameter:

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

{String Parameter: Entry Limit of 1 to 3 characters long} Crpe1.ParamFields[0].ShowDialog := True; Crpe1.ParamFields[0].ValueLimit := cTrue; Crpe1.ParamFields[0].ValueMin := '1'; Crpe1.ParamFields[0].ValueMax := '3';

{DateTime Parameter: Entry must be between min and max datetime} Crpe1.ParamFields[1].ShowDialog := True; Crpe1.ParamFields[1].ValueLimit := cTrue; Crpe1.ParamFields[1].ValueMin := '1998,01,01 12:00:00'; Crpe1.ParamFields[1].ValueMax := '1999,01,01 12:00:00'; Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields Methods

ParamFields Add method

Declaration

procedure Add(ParameterName: TCrParameterFieldName; ReportName: TCrParamFieldReportName);

Type

TCrParameterFieldName = string[255];

TCrParamFieldReportName = string[128];

Description

The Add method adds an item to the ParamFields object and sets the internal index to that item. It requires a Parameter Field name and a Report Name as parameters, which should correspond to a Parameter Field Name in the Report and a valid Report Name (the Main Report does not have a Report Name -- use an empty string).

If the Add method is used instead of Retrieve, the steps to using ParamFields are:

1Add an item to the ParamFields object (you must specify the Parameter Field name and Report Name).

2Fill the item's properties (Value, Prompt, etc.) with values.

VCL Reference

477

3When Execute is called, the properties will be sent to the Print Engine.

NOTE: It is easier to use the Retrieve method instead of Add, since it ensures that the number of items, and the Parameter numbers are correct for the current Report.

Example

The Add method can be used to manually add an item to the ParamFields object, instead of using Retrieve:

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

{Specify Parameter Name - must be same as in Report} Crpe1.ParamFields.Add('Parameter1'); Crpe1.ParamFields.Value := 'CA';

Crpe1.Output := toWindow; Crpe1.Execute;

ParamFields Clear method

Declaration

procedure Clear;

Description

This method can be used to clear the internal memory of the ParamFields object. 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 ParamFields object of the current Report/Subreport specified in the Subreports object. Therefore, to clear all the ParamFields of all the Subreports will require a looping procedure that goes through each Subreport and applies the Clear method:

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

Crpe1.Subreports[cnt];

Crpe1.ParamFields.Clear; end;

Example

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

Crpe1.ParamFields.Clear;

This code clears the ParamFields properties for the second Subreport:

Crpe1.Subreports[2];

Crpe1.ParamFields.Clear;

VCL Reference

478

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