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

Example

This example uses the AsDate property to pass in a native Delphi datetime variable to the ParamFields Value property:

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

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsDate := Now;

Crpe1.Execute;

ParamFields AsDateTime property

Declaration

property AsDateTime: TDateTime;

Description

The AsDateTime property is a run-time property that allows for reading and writing of the Value property (which is a string type) using native Delphi TDateTime values. This property should only be used if the ParamField is actually specified as DateTime (the ParamType is pfDateTime).

Example

This example uses the AsDateTime property to pass in a native Delphi datetime variable to the ParamFields Value property:

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

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsDateTime := Now;

Crpe1.Execute;

ParamFields AsNumber property

Declaration

property AsNumber: double;

Description

The AsNumber property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi number values. Whereas the Value property holds the ParamFields value as a string, AsNumber will return the value as a number type, or can be written to with a number type.

VCL Reference

439

Example

This example uses the AsNumber property to pass in a native Delphi number variable to the ParamFields Value property:

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

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsNumber := 1;

Crpe1.Execute;

ParamFields AsTime property

Declaration

property AsTime: TDateTime;

Description

The AsTime property is run-time only and can be used to read and write the ParamFields.Value property with native Delphi DateTime values. Whereas the Value property holds the ParamFields value as a string, AsTime will return the value as a datetime type, or can be written to with a datetime type.

Example

This example uses the AsTime property to pass in a native Delphi datetime variable to the ParamFields Value property:

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

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].AsTime := Now;

Crpe1.Execute;

ParamFields CurrentValue property

Declaration

property CurrentValue: string

Description

The CurrentValue property indicates the Parameter Value that was last entered into the Parameter Field Prompt Dialog.

The Retrieve method must be used first, before CurrentValue will contain anything.

If the Report does not have Saved Data, CurrentValue will be an empty string until the Report is run at least once (Note that in this case, Retrieve must be called again after the Report has been run in order to show the last value sent to the Parameter Field).

VCL Reference

440

NOTE: CurrentValue is included primarily as a reference property, and is not used when the ParamFields are sent to the Print Engine, so changes to it will not be reflected when the Report is run. Instead, any changes desired should be made to the Value property.

New Features for SCR 7.0

With Seagate Crystal Reports 7.0, multiple Current Values are possible for a Parameter Field. These are handled via the CurrentValues property, which is a StringList.

Example

This example copies the CurrentValue to the Value property for the first ParamField. This only makes sense if the Report has already been run once, or it has Saved Data:

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

Crpe1.ParamFields[0].Value := Crpe1.ParamFields[0].CurrentValue; Crpe1.ParamFields[0].ShowDialog := True;

Crpe1.Output := toWindow; Crpe1.Execute;

ParamFields CurrentValues property

Declaration

property CurrentValues: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

CurrentValues is a StringList that contains multiple values that are to be passed to a Crystal Parameter Field. CurrentValues will only apply if the ParamField.Info.ValueType = vtDiscrete. Otherwise, the Ranges object will apply.

Assuming that the Info.ValueType is vtDiscrete, when the Retrieve method of the ParamFields object is called, the CurrentValues stringlist will contain any current values that have been set for a ParamField. Normally there would not be any, unless the Report has Saved Data, or it has just been run once already.

The most common use of CurrentValues would be to pass multiple values into a ParamField when the Parameter prompt dialog is going to be bypassed. In this case, the values should be added to the CurrentValues stringlist, and the ShowDialog property should be set to False. Note that if the ParamField.Info.AllowMultipleValues property is False, only the first item in the CurrentValues stringlist will be used in the Report. On the other hand, if AllowMultipleValues is true, then all the values will be used in the Report. In this case, the Report must be designed to handle a ParamField which has an array of values in it (see the CRW.HLP for information on using arrays in formulas).

VCL Reference

441

NOTE: To read and write CurrentValues using native Delphi types (boolean, currency, datetime, etc.), use the following methods:

Reading

StrToBoolean

StrToDate

StrToDateTime

StrToFloating

StrToTime

Writing

BooleanToStr

DateTimeToStr

DateToStr

FloatingToStr

TimeToStr

Extracting Parts

ExDateStr

ExDateTimeStr

ExTimeStr

Example

This example sets 2 CurrentValues for the first ParamField. These will be passed directly into the Report, bypassing the Crystal Parameter prompt dialog:

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

{Use values instead of ranges} Crpe1.ParamFields[0].Info.ValueType := vtDiscrete; {Allow more than one value, ie. an array} Crpe1.ParamFields[0].Info.AllowMultipleValues := cTrue; Crpe1.ParamFields[0].ShowDialog := False;

{Clear it, just in case...} Crpe1.ParamFields[0].CurrentValues.Clear; Crpe1.ParamFields[0].CurrentValues[0] := 'Atkinson'; Crpe1.ParamFields[0].CurrentValues[1] := 'Jones'; Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields DefaultValue property

Declaration

property DefaultValue: string

VCL Reference

442

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