How to: Pass Parameters to a Report

  • 2 minutes to read

This tutorial describes the steps used to create a parameterized report. In this tutorial, we will create a string parameter and pass it to the report's filtering expression. You are neither limited by the number of parameters you can create, nor by the data type (e.g., string, date-time, Boolean, integer and double).

Follow these steps to create a report with parameters.

  1. Create a Snap application and bind it to the "Products" table in the sample Northwind database.
  2. To create a parameter, switch to the Data Explorer window, right-click the Parameters section and choose Add Parameter.

    Snap_AddParameter

  3. Right-click the created parameter and select the Edit Parameters... action in the invoked popup menu.

    Snap_EditParameters

  4. In the invoked editor, define the parameter name and assign an appropriate type to it. This type corresponds to the value that a parameter can receive (e.g., you cannot assign a string value to a numeric parameter).

    Next, assign a default static value to the parameter.

    Snap_CollectionEditor

  5. Now switch to the List tab in the Main toolbar and click the Filter button.

    In the invoked FilterString editor, define a filtering expression (e.g., where the UnitPrice data field is greater than or equal to the Starting Price parameter).

    To access the parameter, click the icon on the right until it turns into a question mark, and then select your parameter from the drop-down list.

    Snap_FilterString

  6. To create a layout for your report, drop the ProductName and UnitPrice data fields from the Data Explorer onto the report's surface.

    Snap-Create-Report-with-Parameters-01

The parameterized report is now ready, and its data is filtered based on the specified expression that uses the parameter value to shape the report's data.

To view how your report will look on paper, switch to the File menu in the Main toolbar and click the Print Preview button.

Snap_ReportWithParameter

If required, you can easily modify the parameter value in code. To learn more on this, see How to: Pass Parameters to a Report (Runtime Sample).