ActiveReports 8
Add Parameters in a Section Report
Show AllShow All
Hide AllHide All

There are several ways to add parameters in a section report. The following sections provide a step by step overview of adding parameters in a report.

To add parameters using the Report Explorer

  1. In the Report Explorer, right-click the Parameters node and select Add. This adds a parameter (Parameter1) as a child to the Parameters node.


  2. Select the added parameter to open the Properties Window and set values in the following properties:
    • Name: This is the unique name of the parameter which appears as Parameter1 by default. It corresponds to the Key property in parameters entered via code.
    • Default Value: Sets/returns the value displayed when the user is prompted to enter a value at runtime.
    • Prompt: Sets/returns a string displayed when a user is prompted for the value at runtime.
    • PromptUser: Boolean value that indicates whether to prompt the user for a value or not. This is set True to use parameters at runtime.
    • Type: This value which defaults to String defines the type of data the parameter represents. You can also set data type to Date or Boolean.
  3. Pass the parameter to a field on the report, or access it programmatically as described in the run time procedure below.

To add parameters directly using a SQL query

When you add SQL parameters to a report, ActiveReports displays an Enter Report Parameters dialog where the user can enter the values to fetch from the database.

  1. In the detail section band, click the DataSource icon to view the Report Data Source dialog.
  2. Connect the report to a data source, for example, OleDb data source. See Bind Reports to a Data Source for further details.
  3. In the Query field, enter a SQL query like the one below, which contains the parameter syntax to prompt for parameter values at runtime.
    SELECT * FROM Products
    INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID= [Order Details].OrderID) ON Products.ProductID = [Order Details].ProductID WHERE Products.SupplierID = <%SupplierID|Enter Supplier ID|7%>
    AND OrderDate >= #<%OrderDate|Order date from|11/1/1994|D%>#
    AND Discontinued = <%Discontinued|Is this checked?|true|B%>
  4. Click OK to save the data source and return to the report design surface.

The SQL query above causes ActiveReports to display the following dialog to the user. The user can accept these or input other values to select report data.

To add parameters at run time

You can add, edit, and delete parameters at run time. The following code demonstrates how to add a parameter and display its value in a Textbox control.

  1. Double-click in the gray area below the report to create an event-handling method for the ReportStart event.
  2. Add code to the handler to set parameters at run time.

    To write the code in Visual Basic.NET

    To write the code in C#

  3. In the design view, click the gray area below the report to select it and open the Properties Window.
  4. Click the events icon in the Properties Window to display available events for the report.
  5. Double-click FetchData. This creates an event-handling method for the report's FetchData event.
  6. Add code to the handler to pass the parameter at run time.

    To write the code in Visual Basic.NET

    To write the code in C#

The runtime implementation above causes ActiveReports to display the following dialog to the user. The user can enter any text in this prompt dialog and display it on the report.

Viewing a Parameterized Report

The parameter prompt dialog for a parameterized report depending on how you view the report.

To get a Parameter Dialog box

To get a Parameter Panel in the Viewer sidebar

See Also

Concepts

Support Forum