Crystal report application advanced parameter function

zhaozj2021-02-16  56

Advanced parameter features There are many ways to use parameters within the report. This section describes some advanced methods for using parameters:

1. Create parameter 2 with multiple values, use the parameter field application condition format setting 3, create a report title 4 using the parameter field, specify a single value or range value 5, including the parameters in the formula 6, use the parameter field to define the sort order 7. Use the edit mask to define the input type and format ------------------------------ 1, create more The parameters of the value click Field Explorer on the View menu. Select the "parameter field" and click New. Enter "Name" and "Tips Text". Select "Value Type". Select the "Allow Multiple Value" checkbox to enable multiple values ​​to the parameters. Allows the use or combination of values ​​and values ​​of the discrete types and range types. Note: For more information on a single value or range value, see Specify a single value or range value.

Click Set Defaults to determine the type of input value allowed. The Set Default dialog box appears.

Select the list of default values ​​from the "Browse Table" drop-down list. Select the field of the default value from the "Browse Field" drop-down list. The value associated with the table and field appears in the "Value or Enter the value" area.

Select the listed values ​​or create your own values, then use the arrow buttons to move them to the Defaults area. Adjust display, order, and length restrictions as needed. Click OK. ---------------------------------- 2, using the parameter field application condition format Setting parameter fields can be used to create conditional format Set formula. These formulas can be customized whenever refresh report data. Conditional Format Settings Formulas can be used to make color tags for data that meet specific conditions. E.g:

Sales representatives with more than 10% limit. There is no customer in the previous quarter. There is no turnover inventory for last month. If you mark these items, you don't need to use the parameter field. You can use only formulas (for text tags) or conditional format settings (for border tags). However, if you want to change the conditions between your reports, you need to use the parameter field in the formula and condition format setting formula.

Set the parameter field of the data type required for the formula using the parameter field application condition format. Create a formula and use the parameter field instead of the commonly used fixed value. For example, to let the program prompts all customers who purchase the amount over a specific value and print their name into red, select the "Last Year Sales" field and click "Format" on the Expert Toolbar.

"Format Editor" appears.

Click the Conditional Formula button next to the "Color" attribute on the Fonts tab, and use the condition format setting formula to format the fields, as shown below: if {Customer. Last year sales}> {? SalesTarget} Then Red else Black

Now, when refreshing data, the program will prompt you to enter the value of the trigger color tag (called threshold), then run the report and tag all customers above the threshold number last year. This number can be changed while running the report, the program will mark different "Customer Name" groups. For more information, see Conditional Format Functions (Basic Syntax). ---------------------------------- 3, create report titles using the parameter field Crystal Reports enables you to use the parameter field Create report titles that can be changed when refreshing reports.

Creating a report Title on the View menu using the parameter fields Click Field Explorer. "Field Explorer" appears.

Select the "parameter field" and click New. The Create Parameter Field dialog box appears.

Type the name of the parameter field in the Name field. Type any prompt text you need in the "Tip Text" field. Select "String" from the "Value Type" drop-down list. Click Set Defaults. The Set Default dialog box appears.

To specify the default title, type the desired text in "Select or Enter the Value" field, then click> Add the title to the Default area. Note: Continue to add titles as needed.

Click OK. The Create Parameter Field dialog box appears.

Click OK. "Field Explorer" appears, where the new parameters are selected.

Place the parameter field in the "Header" section of the report so that the title appears in each page; or if you want the title to appear only in the first page of the report, put it in the Report Title section. Now, when refreshing data, the program will prompt you to enter the report title. If necessary, change the title when you run the report. -------------------------------- 4, specify a single value or range value can be created for users to enter a single ( The parameters of the discrete) value can also create parameters that require user input range values. If these parameters are then included in the reported record selection area, they can help users find specific information. For example, in the case where the selection parameter uses the discrete value, the user can enter a single country name so that only sales of the country. In the case where the selected parameter is recorded, the user can enter a country of the country (for example, Canada and France) to view all countries in this range (including Chili, China, Denmark. , England, etc.).

Specify a single value or range value to select the Discrete value option or the range value option to specify whether the parameter field accepts the range value. If "Discrete Value" is selected, the parameter field will accept a single value (not the range value). If you select a range value, you can enter the starting value and the end value when prompted to enter the parameter value. For example, if input value "5" and "10", the range is 5-10, and this parameter is used to record the report of the selected area to display all records between the values ​​5 and 10. This also applies to the string parameter field. For the starting value "a" and the end value "E", this parameter is used to record the report of the selected area to display all records in the alphanumeric A-E. Note: If you select Allow Multiple Values ​​and Discrete Value options, the parameter field will accept multiple individual values. In this case, multiple values ​​can be entered, but these values ​​will be respectively evaluated and will not be interpreted as a range. If the "Allow Multiple Values" and "Ran Value" options are selected, the parameter field will accept multiple scope. If you are available, click Set Defaults to select the Length Restrictions check box to specify the length of the field. If you select a "Length Limit" check box: For the "Money" or "Digital" parameter field, you will appear to enter the "minimum" and "maximum" option. For the Date Time parameter field, an option for entering "Start Date Time" and "End Date Time" appears. For the Date parameter field, an option for entering "Start Date" and "End Date" appears. For the "Time" parameter field, an option for entering "start time" and "end time" appears. -------------------------------- 5, include the parameters in the formula in the View menu. Field Explorer. "Field Explorer" appears.

Select the "parameter field" and click New. The Create Parameter Field dialog box appears.

Create a parameter field and save it. Select "Formula Field" and click New. The Formula Name dialog box appears.

Enter the name of the formula, and then click Use Editor. Use the parameter field to create a formula like using a constant value. For example, with its creation of national and region name hardcodes: {Customer. Country and Region} = "USA"

Use the parameter field instead of "USA".

{Customer. Country and Region} = {? Country}

To do this, double-click the Database field, press = key, then double-click the parameter.

Tip: You can easily identify the parameter field by looking for (?).

Click Close upon in the formula studio. The Field Explorer dialog box appears. The formula name just created highlights in the Formula list box.

Drag and drop the formula into the report. Click Refresh to generate a report. The dialog box appears prompts you to enter the value. ---------------------------------- 6, use the parameter field definition sort order To use the parameter field to set the sort order First, you need to create a formula containing the parameter field, and then sort based on the formula. For example, suppose you have a list of customers based on the Customer table. For each customer, "Customer Name", "City", "Regions", "Country and Regions" and "Phone" are displayed. You want to order according to the "Country and Region" according to the needs at the time, according to the "region" or in "city". Creating a parameter field and is called "Sort Field". Enter the following prompts in the "Tips Text" editing box: Type r Sort by "Region", or type c to order "City"; otherwise, data will be sorted by "country and region".

Select "String" from the "Value Type" drop-down list. You may limit the number of characters that can be typed to 1. To do this, click Set Defaults. The Set Default dialog box appears.

Select the Length Limit check box, type the number 1 into the Minimum Length, and the Maximum Length text box, and then click OK. Now, the parameter field will only accept a single character value. This field will accept "c" as a value without accepting "city".

Creating a formula similar to the following is called "sorting": if {? Sortfield} = "c" THEN {? City} else if {? Sortfield} = "r" THEN {Customer. Region} else {Customer. Country and region}

This formula prompts you to enter the value of the parameter field {? Sortfield}. If "C" is entered, the formula will be sorted by "City" field. If you enter "R", press the "Region" field. If you enter other content, or do not enter anything at all, the formula will be sorted according to the "Country" field.

For more information, see the IF statement (Basic syntax).

Place the formula in the Report Header section of the report, then select "Cancel (no deepening) in" Section Expert "to do not output the formula. Click "Sorting Record". Select the formula, and then click Add. Click OK. Now, when running the report, the program will prompt you to enter the sort field, the formula will return the value according to the selected content, and the sorting tool will use this value as the sort field. ---------------------------------- 7, use the edit mask to define the input type and format in the View menu Click Field Explorer. Select the "parameter field" and click New. The Create Parameter Field dialog box appears. Enter "Name", "Tips Text" and "Value Type". Click Set Defaults. For a string parameter field to set the default value, you can choose to enter the editing mask in the Edit Mask field instead of the specified range. The editing mask can be any set of shielded characters, which are used to limit values ​​that can be entered as parameter values ​​(the edit mask also limits the value input as the default prompt value).

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

"A" (allowing alphanumeric characters and requires input characters in the parameter value). "A" (allowing alphanumeric characters, not required to enter characters in the parameter value). "0" (allowing numbers [0 to 9] and requests to enter characters in the parameter value). "9" (allowing numbers or spaces, not required to enter characters in the parameter value). "#" (Allowing numbers, spaces or plus / minus, no requirements in the parameter value). "L" (allowing letters [a to z] and requires input characters in the parameter value). "?" (Allowing letters, not required to enter characters in the parameter value). "&" (Allowing any characters or spaces to enter characters in the parameter value). "C" (allowing any characters or spaces, no requirement to enter characters in the parameter value). ",:; - /" (separated characters). Insert the separated character in the editing mask is a bit like a hard-encoded format setting of the parameter field. After placing the fields on the report, the dividing character will appear in the field object framework, just like this: LLLL / 0000. This example describes the four letters of editing mask with 4 numbers. "<" (So that the subsequent characters are converted to lowercase characters). ">" (So that the subsequent characters are converted to uppercase characters). "/" (So that the subsequent characters are displayed as a literal value). For example, editing mask "/ a" will display the parameter value "a". If the edit mask is "00 / A00", the valid parameter value will contain two numbers, letters "a" and two other numbers. "password". Allows the edit mask to "password", creating a conditional formula Specifies some part of the report only to be visible after entering a specific user password. Note: Some editing mask characters require in their location to enter characters (when entering the parameter value), while others allow the space to be retained when needed. For example, if the edit mask is 000099, the parameter value of 4 numbers, 5 numbers, or 6 numbers can be entered because the editing mask character "9" does not require input characters. However, since "0" requires input characters, the input parameter value cannot be less than 4 numbers. Add values ​​to "Select or Enter the value" list or highlight the value in the list, and use> and >> buttons to add these values ​​to the Defaults list to enter the default prompt value. You can use the

Click OK. The Create Parameter Field dialog box appears.

Note: When there are multiple items in the Defaults list box, the Allow Edit Defaults will appear check boxes. The check box is selected by default to specify that you can edit or enter a new value after prompting the parameter value. Select or clear the check box as needed.

Click OK. The Field Explorer dialog box appears, where the parameters are selected.

Drag and drop this parameter into the report.

转载请注明原文地址:https://www.9cbs.com/read-22471.html

New Post(0)