ActiveReports allows you to use parameters to filter or add the data to display in reports. You can either prompt users for parameters so that they control the output, or supply the parameters behind the scenes.
In a Page or an RDLX report, the easiest way to build queries with parameters is to use the Visual Query Designer, as it automatically sets up each parameter.
In the DataSet dialog, click on to access Visual Query Designer to create SQL queries. See Query Builder in Microsoft SQL Client and OLEDB Providers for further information on creating a parameterized query using the interactive query designer.
However, if you would like to create parameterized query manually, you must enter each parameter in three locations:
The Report - Parameters dialog allows you to control how and whether a user interface is presented to your users for each parameter. Parameter values are collected in the order they appear in the Report Parameters collection. You can change the order using the arrows in the Report - Parameters dialog.
The Report - Parameters dialog contains a parameters page with a list of parameters and three tabs to set parameter properties. You need to set the following properties in the dialog to create a parameter:
The tabs in the Report - Parameters Dialog are explained below.
You can access the Report - Parameters dialog through any one of the following:
On the Parameters page of the DataSet Dialog, pass a Report Parameter into the parameter in your query. You can click the Add (+) icon at the top of the parameters list, enter parameter name, and supply a value like:
=Parameters!MPAA.ValueOn the Query page of the DataSet Dialog, enter the parameter in the SQL query. Use the syntax specific to your data source type to create a parameter. For example, with an OleDB data source, add a query like the following for a multi-value Movie Rating parameter:
SELECT * FROM Movie WHERE (MPAA = ? AND YearReleased = ?)
If you want to run a report without prompting the user for a value at run time, you need to set a default value for each parameter, and the Hidden check box should be selected in the Report - Parameters dialog > General tab.
Subreport parameters are also considered hidden parameters, as a user can easily synchronize a subreport's data with that of the parent report. See Subreport for further details.
Drill-Through parameters are also hidden parameters, as drill-through links are used to navigate from one report to another. When you select Jump to report for the action, the parameters list is enabled.
A query parameter can get its value from the Report Parameters collection (entered by the user or from a value you supply), a field in another dataset, or an expression. Syntax for adding a parameter in your query might differ depending upon the data source that you are using. Use the syntax specific to your data source type to create a parameter.
Parameterized query for different data sources are as follows:
Data Source | Parameter Syntax | Example |
---|---|---|
OleDB | (?) |
|
ODBC | (?) |
|
SQL Client | @ParameterName |
|
OracleDB | :ParameterName |
|