ActiveReports for .NET 3 Online Help Request technical support
Walkthrough: Parameters with Simple Reports
See Also
User Guide > Samples and Walkthroughs > Walkthroughs > Standard Edition Walkthroughs > Advanced > Parameters Walkthroughs > Walkthrough: Parameters with Simple Reports

Glossary Item Box

In ActiveReports, the Parameters dialog can be used to prompt for user input when reports are generated. If you add "<%FieldName | PromptString | DefaultValue | Type %>" to the report's SQL string, the Parameters dialog appears when the report opens. 

This walkthrough illustrates the basics of using parameters in simple reports.

The walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\Data Dynamics\ActiveReports for .NET 3.0\Data\NWIND.MDB.

When you have finished this walkthrough, you will have a report that looks similar to the following.

Adding an ActiveReport to a Visual Studio project

To add an ActiveReport to your project

  1. Open a new project in Visual Studio.
  2. From the Project menu, select Add New Item.
  3. Select ActiveReports 3.0 File and rename the file rptParams.
  4. Click Open.

Connecting the report to a data source

To connect the report to a data source

  1. Click on the gray report DataSource icon in the Detail section to open the report DataSource dialog.
  2. Select the "OLE DB" tab.
  3. Click Build.
  4. Select Microsoft Jet 4.0 OLE DB Provider and click Next.
  5. Click the ellipsis button to browse for the access path to the NorthWind database. Click Open once you have selected the appropriate access path.
  6. Click OK to continue.
  7. In the Query field, type "SELECT * FROM orders INNER JOIN [order details] ON orders.orderid = [order details].orderid WHERE orderdate =#<%Date|Order date:|1/1/1994|D%>#".
  8. Click OK to return to the report design surface.

Adding controls to the report to contain data

To add controls to the report

  1. Add a GroupHeader/Footer section to rptParams by right-clicking on the report design surface and selecting Insert > GroupHeader/Footer.
  2. Make the following changes to the group header:
    • Change the Name property to ghOrders
    • Change the BackColor property to Orchid
  3. Add the following controls to the GroupHeader section:

    Control Name Text Location
    Label lblOrderDate Order Date 0, 0
    Label lblShipName Ship Name 1, 0
    Label lblShipAddress Ship Address 3, 0
  4. Change the BackColor property of the detail section to Plum.

  5. In the Report Explorer, expand the Fields node, then the Bound node. Drag the following fields onto the detail section and set the properties of each textbox as indicated. 

    Field Text Location Miscellaneous Size
    OrderDate Order Date 0, 0 OutputFormat = MM/dd/yy 1, 0.19
    ShipName Ship Name 1, 0 1.9, 0.19
    ShipAddress Ship Address 3, 0 1.7, 0.19

Viewing the report

To view the report

  1. Add the ActiveReports viewer control to a Windows Form.
  2. Add the code needed to set the viewer document equal to the report document. See Using the ActiveReports Windows Form Viewer for help.
  3. When you run the report, a parameter UI is presented. Enter 9/2/94 to see the report shown above.
You can quickly view your report at design time by clicking the Preview tab at the bottom of the designer.

See Also

©2009. All Rights Reserved.