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

It is strongly recommended that you leave SendOnExecute to True, and let the Crystal Reports component send the values to the Print Engine. If you set the SendOnExecute property to False, each Sub-class and each property that does not belong to a Sub-class must be manually sent before calling the Execute method. This feature is mainly provided for debugging purposes.

Example

In this example, the ParamFields Ranges settings for the first ParamField are sent from the Crystal component to the Crystal Reports Print Engine DLL. This is normally handled automatically for each ParamField in the ParamFields.Send method which is in turn called by the Execute method:

Crpe1.ParamFields[0].Ranges.Send;

ParamFields ReportName property

Declaration

property ReportName: string;

Description

ReportName is a runtime, read-only property that specifies which Report the Parameter applies to. It will only contain a meaningful value if the Retrieve method is used to fetch the ParamFields items. Any Parameters that apply to the main Report will have a blank value for ReportName.

NOTE: For Subreports, the ReportName property holds the same value as the ReportTitle and Subreports.Name properties. If the ReportTitle for a Subreport is changed, it is recommended that the Subreports and ParamFields objects be cleared and reloaded before attempting to run the Report twice in a row.

Example

In this example, because there are two Parameter fields with the same name (one in the main Report and one in the Subreport), the ReportName property is checked to distinguish the ParamFields:

var

cnt: integer; begin

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

for cnt := 0 to Crpe1.ParamFields.Count - 1 do begin

if Crpe1.ParamFields[cnt].ReportName = 'Sub1' then Crpe1.ParamFields[cnt].Value := 'CA';

else

Crpe1.ParamFields[cnt].Value := 'WA';

end;

Crpe1.Output := toWindow; Crpe1.Execute;

end;

VCL Reference

471

ParamFields ShowDialog property

Declaration

property ShowDialog: boolean;

Description

The ShowDialog property determines if the Parameter prompt dialog box will appear or not. There are two ways to use Parameter Fields at runtime:

1.Pass a value directly into the Parameter without seeing the Parameter prompt dialog box. In this case, ShowDialog should be set to False.

2.Change the default value that the Parameter contains, but show the Parameter prompt dialog anyway to allow the user to change it. In this case, ShowDialog should be set to True.

The default value for ShowDialog is False.

Example

In the example below, one Parameter field will not be prompted for, and the other one will. When the prompt dialog box appears, 'WA' will be the default value:

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

{Change value and do not prompt for this one} Crpe1.ParamFields[0].Value := 'CA'; Crpe1.ParamFields[0].ShowDialog := False; {Change value but prompt for this one} Crpe1.ParamFields[1].Value := 'WA'; Crpe1.ParamFields[1].ShowDialog := True; Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields Value property

Declaration

property Value: string;

VCL Reference

472

Description

The Value property specifies the value that is to be passed into the Parameter field. This must be formatted as a string, regardless of the ParamType. Here are some examples which show how to pass each Parameter type:

ParamType

Value

 

 

pfNumber

'235'

 

 

pfCurrency

'2.35'

 

 

pfBoolean

'True'

 

 

pfDate

'1999,01,30' {YYYY,MM,DD}

 

 

pfString

'Vancouver'

 

 

pfDateTime

'1999,01,30 1:12:14' {YYYY,MM,DD HH:MM:SS} {SCR 7 only}

 

 

pfTime

'1:12:14' {HH:MM:SS} {SCR 7 only}

 

 

There are six other properties that can be used to read and write the Value property using native Delphi types: AsNumber, AsCurrency, AsBoolean, AsDate, AsDateTime, AsTime.

NOTE: With SCR 7, multiple default and current values can be passed as Parameters. A default value is one that will appear in the Parameter prompt dialog for possible selection by the user. A current value is one that is a Parameter value that has already been selected and passed into a Report Parameter, either by the programming front-end, or by the user selecting an item in the Parameter dialog.

With the last Crystal 6 version of the VCL, only the Value property was of concern, and if the ShowDialog property was set to True, the Value property was passed to the Report as a default value; if the ShowDialog property was set to False, the Value property was passed into the Report as a current value.

However, with this new release, since it is possible to have multiple default and current values, a simple string property is not good enough to handle this. So two new StringList properties were added: DefaultValues and CurrentValues. If the DefaultValues or CurrentValues properties of the ParamFields object have values in them, these will take precedence over what may be stored or set in the Value property.

NOTE: Very Important! Because DefaultValues and CurrentValues will take precedence over the Value property, it would be a good idea to copy the Value property into the DefaultValues[0] string, or the CurrentValues[0] string, to make sure the string stored in the Value property gets passed in to the Report without being overwritten by DefaultValues[0] or CurrentValues[0].

VCL Reference

473

Example

This example illustrates the Value and AsDate, etc. properties to set Parameter Field values:

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

Crpe1.ParamFields.Retrieve;

Crpe1.ParamFields[0].Value := 'CA';

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

Crpe1.ParamFields[2].AsNumber := 3;

Crpe1.ParamFields[3].AsBoolean := True;

Crpe1.ParamFields[4].AsCurrency := 1.23;

Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields ValueLimit property

Declaration

property ValueLimit: TCrBoolean;

Type

TCrBoolean = (cFalse, cTrue, cDefault);

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

474

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