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

Description

The DefaultValue property indicates the Default Prompting Value that was entered for a Parameter Field when the Parameter was created in Crystal Reports.

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

The DefaultValue is automatically copied to the Value property when the Retrieve method is called.

If the Report has already been run at least once, and the ShowDialog property was set to True, DefaultValue will indicate the value that appeared (before being edited) in the Parameter Prompt dialog (Note that in this case, Retrieve must be called again after the Report has been run in order to show the last default value).

NOTE: DefaultValue 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 Default Values are possible for a Parameter Field. These are handled via the DefaultValues property, which is a StringList.

Example

This example displays the DefaultValue for the first ParamField:

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

Crpe1.ParamFields.Retrieve;

ShowMessage(Crpe1.ParamFields[0].DefaultValue);

ParamFields DefaultValues property

Declaration

property DefaultValues: TCrpeString;

Type

TCrpeString = class(TStringList)

Description

DefaultValues is a StringList that contains multiple values that are to be passed as possible choices to a Crystal Parameter Field. These values will not actually be used in the Parameter until the user selects them when the Parameter prompt dialog appears. If you do not want the Parameter prompt dialog to appear, you should use the CurrentValues property instead.

VCL Reference

443

When the Retrieve method of the ParamFields object is called, the DefaultValues stringlist will contain any default values that have been entered as options for a Parameter. Normally this would have been done when the Parameter was created in the Report, but could also be those items that were sent in as default values from a previous run of the Report (provided the Report is still in memory).

The most common use of DefaultValues would be to edit or add to the list of multiple values that will be available for the user to choose from when the Parameter prompt dialog appears. In this case, the ShowDialog property should be set to True.

NOTE: To read and write DefaultValues 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 DefaultValues for the first ParamField. These will be offered as choices when the Parameter prompt dialog appears:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.ParamFields.Retrieve; Crpe1.ParamFields[0].ShowDialog := True; {Clear it, just in case...} Crpe1.ParamFields[0].DefaultValues.Clear;

Crpe1.ParamFields[0].DefaultValues[0] := 'Atkinson'; Crpe1.ParamFields[0].DefaultValues[1] := 'Jones'; Crpe1.Output := toWindow;

Crpe1.Execute;

VCL Reference

444

ParamFields EditMask property

Declaration

property EditMask: string;

Description

The EditMask property can be used to control the type of data that can be input into the Crystal Parameter prompt dialog's edit field. It is only applicable to string-type parameters (ParamType = pfString).

The EditMask can be any of a set of masking characters used to restrict the values that can be entered. Some of the Edit Mask characters require that a character be entered in their place, while others are optional placeholders, and still others act as separator characters.

For example, if the EditMask is 000099, a parameter value with four digits, five digits, or six digits can be entered by the user, since the "9" EditMask character does not require the entry of a character. However, since "0" does require such an entry, a parameter value with less than four digits cannot be entered.

A - allows an alphanumeric character and requires the entry of a character in the parameter value.

a - allows an alphanumeric character and does not require the entry of a character in the parameter value.

0 - allows a digit [0 to 9] and requires the entry of a character in the parameter value.

9 - allows a digit or a space, and does not require the entry of a character in the parameter value.

# - allows a digit, space, or plus/minus sign, and does not require the entry of a character in the parameter value.

L - allows a letter [A to Z], and requires the entry of a character in the parameter value.

?- allows a letter, and does not require the entry of a character in the parameter value.

&- allows any character or space, and requires the entry of a character in the parameter value.

C - allows any character or space, and does not require the entry of a character in the parameter value.

.,:;-/ - separator characters.

Inserting separator characters into the EditMask is similar to hard coding the formatting for the Parameter field. When the field is placed on the report, the separator character will appear in the field object frame, like this: LLLL/0000. This example depicts an edit mask that requires four letters followed by four numbers.

<- causes subsequent characters to be converted to lowercase.

>- causes subsequent characters to be converted to uppercase.

\ - causes the subsequent character to be displayed as a literal. For example, the Edit Mask "\A" would display a parameter value of "A." If the Edit Mask is "00\A00," then a valid parameter value would consist of two digits, the letter "A," and then two additional digits.

VCL Reference

445

Password - if the EditMask is set to "Password", the Parameter prompt dialog will show

only "****" characters in the edit field. In this way, conditional formulas can be created specifying that certain sections of the report will be visible only when certain user passwords are entered.

Example

This example sets an EditMask for the first ParamField, "parameter1". The mask is to be used for a State abbreviation, "CA", "WA", etc.:

Crpe1.ReportName := 'C:\Company.rpt'; Crpe1.ParamFields.Retrieve; Crpe1.ParamFields[0].ShowDialog := True;

{Requires two letters, they will be converted to uppercase} Crpe1.ParamFields[0].EditMask := '>LL'; Crpe1.Selection.Formula.Text := '{company.STATE} = {?parameter1}'; Crpe1.Output := toWindow;

Crpe1.Execute;

ParamFields Info property

Declaration

property Info : TCrpeParamFieldInfo;

Type

TCrpeParamFieldInfo = class(TPersistent)

Description

Only available with Seagate Crystal Reports 7 and higher. The Info sub-class contains 7 properties that refer to extra Parameter Field options.

The AllowEditing property determines if the Parameter Field can be edited in the Prompt Dialog.

The AllowMultipleValues property determines if the Parameter Field will accept more than one value.

The AllowNull property determines if the Parameter Field will accept a null value; that is, whether it can be left blank in the Prompt Dialog. This property only applies to Stored Procedure Parameters, which are now read through the ParamFields object, instead of SQL.Params as with former versions of Crystal Reports.

The PartOfGroup property determines if the Parameter Field is grouped with other Parameter Fields. If it is, it will appear on the same tab of the Prompt Dialog as the other Parameters it is grouped with.

The GroupNum property specifies the Group number that the Parameter Field belongs to. This only applies if PartOfGroup is set to cTrue.

VCL Reference

446

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