Glossary Item Box

Walkthrough: Exporting Output | Samples | Walkthroughs

See Also ActiveReports for .NET 2 Online Help Send feedback to Data Dynamics

Walkthrough: Merging Reports

ActiveReports allows you to merge two or more reports in Visual Studio for previewing in the viewer control or printing. The document containing the merged reports can also be saved to an RDF file or exported.

This walkthrough illustrates how to create two ActiveReports and merge the reports into one document.

This walkthrough is split up into the following activities:

To complete the walkthrough, you must have access to the NorthWind database (NWind.mdb).

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

Adding two ActiveReports to a Visual Studio project

To add two ActiveReports to a Visual Studio project

  1. Open a new project in Visual Studio.
  2. Click on Project > Add New Item.
  3. Select ActiveReports file and rename the file rptOne.
  4. Click Open.
  5. Click on Project > Add New Item.
  6. Select ActiveReports file and rename the file rptTwo.
  7. Click Open.

Connecting the reports to a data source

To connect rptOne to a data source

  1. Click on the yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click on Build...
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next >>
  4. Click on the ellipsis to browse for the access path to NWind.mdb. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from orders".
  7. Click OK to return to the report design surface.

To connect rptTwo to a data source

  1. Click on the yellow report DataSource icon in the Detail section. This brings up the report DataSource dialog box.
  2. Click on Build...
  3. Select Microsoft Jet 4.0 OLE DB Provider and click Next >>
  4. Click on the ellipsis to browse for the access path to NWind.mdb. Click Open once you have selected the appropriate access path.
  5. Click OK to continue.
  6. In the Query field, type "Select * from products".
  7. Click OK to return to the report design surface.

Adding controls to display the data

To add controls to the reports

  1. Add the following controls to rptOne, naming them as indicated:

    Control DataField Name Text/Caption Location
    TextBox OrderDate txtOrderDate Order Date 0, 0
    TextBox OrderID txtOrderID Order ID 1.125, 0
    TextBox ShipName txtShipName Ship Name 2.25, 0
    TextBox ShipAddress txtShipAddress Ship Address 3.375, 0
    TextBox ShipCity txtShipCity Ship City 4.5, 0

  2. Add the following controls to rptTwo, naming them as indicated:

    Control DataField Name Text/Caption Location
    TextBox ProductID txtProductID Product ID 0, 0.06
    TextBox ProductName txtProductName Product Name 1.125, 0.06
    TextBox QuantityPerUnit txtQuantityPerUnit Quantity Per Unit 2.25, 0.06
    TextBox ReorderLevel txtReorderLevel Reorder Level 3.375, 0.06
    TextBox UnitsOnOrder txtUnitsOnOrder Units On Order 4.5, 0.06

Adding code to the Form_Load event

To write the code in Visual Basic

To write the code in C#

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 WinForm Viewer for help.

Walkthrough: Exporting Output | Samples | Walkthroughs

 

 


Copyright © 2004-2005 Data Dynamics, Ltd. All rights reserved.