Report Scheduler - Parameters

Many Crystal Reports will require one or more parameters to be entered when the report is run. These parameters can be dates, times, numbers, text, boolean or currency values. The values supplied can be used to alter the look of the report or in many cases they are used to change the way the report queries the database. An example of this would be to enter a start and end date so the report only shows records between the two dates.

When you run a report from the 'Quick View' screen, Easy View will prompt for any parameter fields required by the report. You can then enter the values in manually. This works fine when you are running reports manually but it presents a problem when running reports automatically from the 'Report Scheduler'. Easy View handles this problem by letting you supply the report parameters from the 'Report Scheduler' screen.

Open Easy View and click on the Report Scheduler tab to view the scheduled reports. If you look in the lower left side of the screen you will see a small grid named 'Report Parameters'. You can enter all the parameters required by each report into this grid starting with the number 1.

Fixed and Dynamic Parameters

Fixed parameters are values that never change no matter how many times you run a report. These values may be a number or text etc.

Dynamic parameters are values that need to change each time the report is run. An example of this is a report that shows data from today. In order for the report to run you may need to supply today's date so that the report can run. Easy View has many dynamic parameter variables built in for this purpose. For more information on this see the Variables section.

Discrete and Range Parameters

Crystal Reports supports 2 types of parameter entries Discrete and Range values.

A Discrete value would be used to specify 1 specific value that you want to match in your query. For example you might run a report to show all employees in the Sales department. Your discrete parameter value might be something like 'SalesDept'.

A Range will usually be something like a range of numbers or dates. For example your report could be used to show all departments with between 10 to 20 employees. In this case you range parameters are 10-20. When range values are entered each range must be surrounded by a [ on the left and ] on the right. For example a range of 10 - 20 is entered [10][20].

Entering Parameters

There are 2 methods you can use to enter the parameter values:

  1. Report parameter screen.
  2. Entering the values directly into the list.

1 - Report parameter screen

Entering the parameters into the Report Parameter screen is the simplest and most reliable way to enter the report parameters.

To access this screen, select a schedule in the list and click the 'Edit' button at the top left of the screen. Once you are in edit mode, right click on one of the rows in the parameter list and click 'Add new' or 'Edit' to change an existing parameter.

Add a new parameter:

  1. Select the parameter name from the list.
  2. Select the parameter type (Discrete or Range).
  3. Enter the parameter value using 1 of the 3 options below:
  4. Click OK to save the parameter settings.
  5. Repeat this process for all parameter values required by the report.

2 - Entering the values directly into the list

Although the Report Parameter screen is the recommended way to add report parameter, you can also put the values into the list manually.

Before you can enter the report parameters into the 'Report Scheduler' you need to know what they are and the order they are required. If you are not sure, you can run the report from the 'Quick Launch' window. When you run the report each of the required parameters will be listed in the required order. Make a note of each parameters value and the order it comes up in the list. This is the order the parameters will be entered into the 'Report Scheduler'.

For Discrete parameters you can use either the numerical index or parameter name to specify which parameter you want to supply to the report. For example the numerical index for the first parameter in the list is 1 the second is 2 etc. If you want to use the parameter name you can enter the name of each parameter in the list instead of the number. It is safest to use the parameter name. The order of parameters may change as reports are modified.

For Range parameters you must use the parameter names in all cases. The numerical index will not work with range parameters.

Go through the following steps to enter the parameters:

  1. Select the report
  2. Click the 'Edit' button. This will unlock the Report Parameter grid so you can add your parameters.
  3. Click on the first row of the grid in the 'Parameter' column.
  4. Enter the number or name the parameter and then click the 'Value' column.
  5. You can either type in a value manually or select a variable from the drop down menu.
  6. Repeat steps 3-5 for each parameter in the report.
  7. Click 'Save'

Sub Reports

Parameters can also be passed to sub reports from the report scheduler. The main difference is the way the parameter name is entered. The sub report must be specified along with the parameter.
Example: MyParameter(MySubReport.rpt)

Testing

When you are done entering the parameters, it is a good idea to test run the report to make sure everything works properly.

  1. Right click on the report in the list.
  2. Click 'Run Now' from the pop up menu.
  3. The report should run automatically without prompting you for any parameter values. If you are prompted for parameters, verify your settings and run the test again.

Parameter Examples

2 fixed discrete parameters: Show items that match a date and text value

Report Parameters
 
Parameter
Value
  1 1/1/2010
  2 Sales Dept

1 fixed range parameter: Show items with a value between 50 and 100 (inclusive).

Report Parameters
 
Parameter
Value
  Quantity [50][100]

Multiple discrete values assigned to 1 parameter: Show items that match certain departments.

Report Parameters
 
Parameter
Value
  1 Sales
  1 Customer Service
  1 Accounting

Report Parameters
 
Parameter
Value
  Department Sales
  Department Customer Service
  Department Accounting

Multiple fixed range parameters: Show items within multiple ranges.

Report Parameters
 
Parameter
Value
  Quantity [1][5]
  Quantity [50][100]
  Quantity [852][1392]

Combination of discrete and range parameters:

Report Parameters
 
Parameter
Value
  Date 4/15/2010
  Price [35.95][82.99]
  Quantity [1000][15000]

Using variables with Discrete and Range parameters:

Report Parameters
 
Parameter
Value
  DateToday <Date>
  DateRange [<Date-30>][<Date+30>]

 

<< Previous - Report Scheduler Index >>