Advanced parameters of the crystal report Application

Source: Internet
Author: User
Tags ranges

Advanced parameter functions
There are many ways to use parameters in a report. This section describes some advanced methods for using parameters:

1. Create a parameter with multiple values
2. Use the parameter field to apply the condition format settings
3. Use parameter fields to create a report title
4. specify a single value or range value
5. include parameters in the formula
6. Use parameter fields to define the sorting order
7. Use the edit mask to define the input type and format
----------------------------------
1. Create a parameter with multiple values
Click field resource manager on the View menu ".
Select "parameter field" and click "new ".
Enter "name" and "prompt text ".
Select "value type ".
Select the "allow multiple values" check box to enter multiple values into the parameter. Discrete value and range value can be used separately or in combination.
Note: For more information about a single value or range value, see specify a single value or range value.

Click "Set default value" to determine the type of input values that can be entered.
The "Set Default Value" dialog box is displayed.

Select the default table from the "Browse tables" drop-down list.
Select the default field from the "Browse field" drop-down list.
The values associated with the table and field appear in the "select or enter the value to be added" area.

Select the listed values or create your own values, and then use the arrow button to move them to the "default" area.
Adjust the display, sequence, and length limits as needed.
Click OK ".
----------------------------------
2. Use the parameter field to apply the condition format settings
The parameter field can be used to create a formula for setting the condition format. You can customize these formulas whenever you refresh report data. The conditional format setting formula can be used to mark the color of data that meets specific conditions. For example:

Sales representatives with sales exceeding 10%.
Customers not ordered in the previous quarter.
There was no inventory for any turnover last month.
Parameter fields are not required if the criteria for marking these items are never modified. You can set only formulas (for text tags) or condition formats (for border tags ). However, to change the conditions between reports, you must use parameter fields in formulas and condition format settings.

Use parameter fields to apply conditional format settings
Create a parameter field of the Data Type required by the formula.
Create a formula and use a parameter field to replace the common fixed value.
For example, if you want the program to prompt all customers who purchased more than a specific value last year and print their names in red, select the "last year's sales" field and click "format" on the "expert Tools" toolbar ".

The format editor is displayed ".

Click the "condition formula" button next to the "color" attribute on the "font" tab, and set the format of the field using the condition format setting formula, as shown below:
If {customer. sales last year }> {? Salestarget} Then
Red
Else
Black

Now, when you refresh the data, the program will prompt you to enter the value that triggers the color tag (called the threshold value), then run the report and mark all customers whose sales last year are above the threshold value. You can change this number every time you run a report. The program will mark different "Customer names" groups.

For more information, see Conditional Formatting functions (basic syntax ).
----------------------------------
3. Use parameter fields to create a report title
Crystal Reports allows you to use parameter fields to create report titles that can be changed each time a report is refreshed.

Use parameter fields to create a report title
Click field resource manager on the View menu ".
"Field Resource Manager" is displayed ".

Select "parameter field" and click "new ".
The create parameter field dialog box is displayed.

In the "name" field, type the name of the parameter field.
In the prompt text field, type any required prompt text.
Select "string" from the "value type" drop-down list ".
Click "Set default value ".
The "Set Default Value" dialog box is displayed.

To specify the default title, type the text you want in the "select or enter the value to add" field, and click> Add the title to the "default" area.
Note: add the title as needed.

Click OK ".
The create parameter field dialog box is displayed.

Click OK ".
The "field resource manager" is displayed, and the new parameter is selected.

Place the parameter fields in the "Header" section of the report to make the title appear on each page. Or, if you want to make the title appear only on the first page of the report, in the report TITLE section.
When you refresh the data, the program prompts you to enter the report title. If necessary, you can change the title each time you run the report.
----------------------------------
4. specify a single value or range value
You can either create a parameter that requires the user to enter a single (discrete) value or create a parameter that requires the user to enter a range value. If these parameters are subsequently included in the selected record area of the report, you can find specific information. For example, when the discrete value is used for the selected parameter in the record, you can enter a single country/region name to view only the sales of that country/region. When the range value of the selected parameter is recorded, you can enter the range of the country (such as Canada and France ), to view the sales of all countries/regions in this range (including chili, China, Denmark, England so on under this condition.

Specify a single value or range value
Select the discrete value option or range value option to specify whether the range value is accepted by the parameter field.
If "discrete value" is selected, the parameter field accepts a single value (instead of a range value ).
If you select "range value", you can enter the start value and end value when prompted to enter the parameter value. For example, if the input values are "5" and "10", the range is 5-10, this parameter is used to record all records between values 5 and 10 in a report of the selected region. This also applies to string parameter fields. For the start value "a" and end value "E", use this parameter to record reports for the selected region to display all records within a letter range A-E.
Note: If you select the "allow multiple values" and "discrete values" options, this parameter field will accept multiple individual values. In this case, you can enter multiple values, but these values will be evaluated separately and will not be interpreted as ranges. If you select the "allow multiple values" and "range value" options, the parameter field accepts multiple ranges.

If available, click "Set Default Value" and select the "length limit" check box to specify the length of the field. If you select the "length limit" check box:
For the "currency" or "Number" parameter field, the options for entering "minimum" and "maximum" appear.
For the "Date and Time" parameter field, the options for entering "start date and End Date and Time" appear.
For the "date" parameter field, options for entering "Start Date" and "End Date" appear.
For the "time" parameter field, options for entering "Start Time" and "End Time" appear.
----------------------------------
5. include parameters in the formula
Click field resource manager on the View menu ".
"Field Resource Manager" is displayed ".

Select "parameter field" and click "new ".
The create parameter field dialog box is displayed.

Create a parameter field and save it.
Select "formula field" and click "new ".
The "formula name" dialog box appears.

Enter the formula name and click "use Editor ".
Use a parameter field to create a formula like a constant value. For example, a hard-coded formula with the name of the country or region created with it:
{Customer. country and region} = "USA"

Replace "USA" with the parameter field ".

{Customer. country and region }= {? Country}

Double-click the database field, press =, and then double-click the parameter.

Tip: Query (?) It is easy to identify parameter fields.

Click Close in the formula studio ".
The "field resource manager" dialog box appears. The name of the created formula is highlighted in the formula list box.

Drag the formula to the report.
Click "refresh" to generate the report.
A dialog box is displayed, prompting you to enter a value.
----------------------------------
6. Use parameter fields to define the sorting order
To use a parameter field to set the sorting order, you must first create a formula containing the parameter fields and then sort them based on the formula. For example, assume that you have a customer list Report based on the "customer" table. For each customer, "customer name", "city", "region", "country and region", and "phone number" are displayed ". You want to be able to sort by country, region, or city based on your current needs.

Create a parameter field and call it "Sort field ".
Enter a prompt similar to the following in the prompt text editing box:
Type R to sort by region, or Type C to sort by city. Otherwise, data is sorted by country and region.

Select "string" from the "value type" drop-down list ".
You may want to limit the number of characters that a user can type to one. To do this, click "Set default value ".
The "Set Default Value" dialog box is displayed.

Select the "length limit" check box, type number 1 in the "minimum length" and "maximum length" text boxes, and then click "OK ".
Currently, the parameter field only accepts a single character value. This field will accept "C" as the value, rather than "city ".

Create a formula similar to the following and call it "sort ":
If {? Sortfield} = "C" then {customer. City}
Else
If {? Sortfield} = "R" then {customer. region}
Else
{Customer. country and region}

This formula prompts you to enter the parameter field {? The value of sortfield. If "C" is entered, the formula is sorted by the "city" field. If you enter "r", it is sorted by the "region" field. If you enter anything else or do not enter anything at all, the formula is sorted by the "country and region" field.

For more information, see if statements (basic syntax ).

Place the formula in the "Report Header" section of the report, and then select "cancel (no deepening)" in "section experts" so that the formula is not output.
Click sort records ".
Select a formula and click Add ".
Click OK ".
When running the report, the program prompts you to enter the sorting field. The formula returns the value based on the selected content, and the sorting tool uses this value as the sorting field.
----------------------------------
7. Use the edit mask to define the input type and format
Click field resource manager on the View menu ".
Select "parameter field" and click "new ".
The create parameter field dialog box is displayed.

Enter "name", "prompt text", and "value type ".
Click "Set default value ".
For the string parameter field for which you want to set the default value, you can choose to enter the edit mask in the "Edit mask" field, instead of specifying the range. The Edit mask can be any group of shielded characters used to limit the value that can be input as the parameter value (the edit mask also limits the value that can be input as the default prompt value ).

You can enter any of the following shielded characters or any combination of these characters:

"A" (letters and numbers are allowed and must be entered in the parameter value ).
"A" (letters and numbers are allowed, and it is not required to enter characters in parameter values ).
"0" (numbers [0 to 9] are allowed and must be entered in the parameter value ).
"9" (a number or space is allowed, and a character is not required in the parameter value ).
"#" (A number, space, or plus/minus sign is allowed, and a character is not required in the parameter value ).
"L" (letters [A to Z] are allowed and must be entered in the parameter value ).
"?" (Letters are allowed. It is not required to enter characters in the parameter value ).
"&" (Any character or space is allowed and must be entered in the parameter value ).
"C" (any character or space is allowed, and a character is not required in the parameter value ).
".,:;-/" (Separator ). Inserting delimiter characters in the edit mask is a bit like setting the hard encoding format for parameter fields. After a field is placed on the report, the delimiter will appear in the Field object framework, as shown in the following code: llll/0000. The description in this example requires an editing mask with four letters followed by four numbers.
"<" (Converts subsequent characters to lowercase characters ).
">" (Converts subsequent characters to uppercase characters ).
"/" (Display subsequent characters as the literal value ). For example, editing the mask "/a" will display the parameter value "". If the edit mask is "00/a00", the valid parameter values will contain two numbers, the letter "A" and the other two numbers in sequence.
"Password ". You can set the edit mask to "password". You can create a conditional formula to specify that some parts of the report are only visible after you enter a specific user password.
Note: Some edit mask characters require entering characters (when the parameter value is entered) at their positions, while others allow spaces when needed. For example, if the edit mask is 000099, because the edit mask character "9" does not require a character input, you can enter a parameter value of 4 numbers, 5 numbers, or 6 numbers. However, because "0" requires a character, the input parameter value cannot be less than four numbers.

Add a value to the "select or enter the value to be added" list or highlight the value in the list, and add these values to the "default" list using the> and> buttons, enter the default prompt value.
You can use the <and <buttons to delete the prompt values from the list. The added item appears in the drop-down list of the "input parameter value" dialog box, which contains the specified default prompt value.

Click OK ".
The create parameter field dialog box is displayed.

Note: when there are multiple "default" lists, the "Allow to edit default" check box appears. By default, this check box is selected to specify that you can edit or enter a new value after prompting you to enter the parameter value. Select or clear this check box as needed.

Click OK ".
In the field Resource Manager dialog box, the parameters are selected.

Drag and Drop this parameter to the report.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.