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

Parameter field objects overview

Parameter fields are fields that prompt you to specify a value each time you refresh the data in your report. When you supply a value, the program runs the report using that value. By using parameter fields in formulas, selection formulas, and in the report itself, you can create one report that you can modify quickly as your needs change. See Formulas 101, Page 321.

Imagine that you are creating a report and you want to include only California records. Without parameter fields, you would enter a record selection formula similar to this:

{customer.REGION} = “CA”

This formula always tests the {customer.REGION} field to see if it holds the value “CA”. If it does, it uses the record in the report. If it does not, it rejects the record. The report runs exactly the way you want it. This is fine if you always want to run the report using only California records. But if you want to run it using records from other states, you have to edit the formula and hard code your changes (for example, if you want to run the report using Arizona records, you would have to change “CA” to “AZ” in the Record Selection Formula Editor or the Select Expert). See How to set up record selection using the Select Expert, Page 263.

Using a parameter field in place of the state field value, however, lets you make changes “on the fly”, without hard coding a new value. Here is how it works...

Set up a parameter field by choosing the PARAMETER FIELD command from the Insert menu. For the purpose of this example, call that parameter field Region.

Use the parameter field in your selection formula. Instead of using the formula:

{customer.REGION} = “CA”

Create a formula similar to this:

{customer.REGION} = {?Region}

392

Seagate Crystal Reports User’s Guide

NOTE: {?Region} is the parameter field you created in Step 1. The program uses the {?ParameterFieldName} format for parameter fields in formulas and Experts.

!Whenever you refresh the data in your report, the program prompts you to supply a value for the parameter field or to accept the default value. When you do, the program selects the records for the report using the value you specified.

Using parameter fields, you can create one report that can be customized quickly to meet a variety of needs.

Multiple parameter fields

Formulas and record selection formulas can contain multiple parameter fields. When using multiple parameter fields, the program prompts you for each parameter before it refreshes the data. Thus, you can use a selection formula similar to the following:

{customer.REGION} = {?Region} AND {customer.LAST YEAR’S SALES} <= {?Sales}

This formula will prompt you first for the region you want to report on and then, for the amount that you want to compare last year’s sales against.

Parameter field considerations

There are a number of things to keep in mind when you are working with parameter fields.

You do not have to place a parameter field in your report in order to use it in a record or group selection formula. You just create the parameter field and then enter it in your formula as you would any other field.

The program supports parameter fields in the following data types: string, number, currency, Boolean, and date.

Parameter Fields

393

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]