Creating a Parameter Field

The first step in creating a parameter field is specifying a name for that field. Once you have created your parameter field, Crystal Reports will enclose this field name in curly brackets, preceded by a question mark to indicate it is a parameter field ({?ParamFieldName}). You can also enter prompting text that will appear whenever the Parameter Field dialog appears, as shown in Figure 3-45. Prompting text should help the user understand what to enter in the value field of the dialog (for example, "Please enter a state for this report.").

By default, any parameter you create will have a default type of String, but there are actually seven different field types you can use, including:

String

For entering alphanumeric text

Currency

For prompting users to enter an integer with two decimal places

Date

Used to enter a standard date, in the format Month/Day/Year

Date Time

For prompting for a date/time string, in the format Month/Day/Year Hour/Minute/Second/AM

Time

For entering the time in the format Hour/Minute/Second/AM

Number

Used to enter a number with variable decimal places

Boolean

Used to prompt users for a true or false response

Figure 3-45

Which field type you choose depends on how you are going to use the field in your report. Other attributes that can be set when creating a parameter field include:

□ Allow Multiple values—Allows you to enter a list of values for your parameter field

□ Discrete — Allows you to enter a single value

□ Range — Allows you to specify an inclusive range, using a start and value

□ Discrete and Range — Allows a combination of the previous two attributes

Most of the attributes discussed here are optional; to create a parameter field, the only requirement is that you give your parameter field a name and choose a field type.

To create a simple parameter field to be used in your report, open the Field Explorer and right-click the Parameter Fields node and select New from the right-click menu. Using the dialog shown in Figure 3-46, type a name for your parameter field. In this example, we have named the parameter field "EnterState."

Figure 3-46

Once you have dragged a parameter field onto your report, you will be prompted to enter a value for the parameter the next time the report is previewed using the Windows report viewer, which we will look at in the next chapter, and the generic parameter prompting dialog, as seen in another example in Figure 3-47.

Next, enter any text you wish to appear when the user is prompted for information (for example, "Please enter an employee ID for this report."). Using the combo box labeled "Value type," select a data type for your parameter field.

Click OK to accept your changes. Your parameter field should now appear within the Field Explorer, ready to be used on your report. To insert a parameter field you have created, you can simply drag it from the Field Explorer onto your report design.

If you are using parameters with a Web application, you will need to set the parameter before you view the report. Otherwise you will receive an error message.

After you have entered a value for your parameter field, that value will be displayed in the report preview until you refresh your report and specify you want to prompt for a new parameter value.

Figure 3-47

Was this article helpful?

0 0

Responses

  • Ashleigh McKay
    How to display multiple values in parameter in crystal reports from vb6?
    6 years ago
  • odetta de luca
    How to set the parameter field in crystal report as combobox from months?
    6 years ago
  • Christina
    How to create crystal report parameter with question mark?
    6 years ago
  • genet
    How to enter prompting text in crystals?
    6 years ago

Post a comment