Glossary Item Box

Samples | Walkthroughs | OutputFormat Strings

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

Walkthrough: Master Detail Reports with Grouping

ActiveReports allows you to create Master Detail reports with grouping by using the GroupHeader and Detail sections to contain data from master files and detail files.

This walkthrough illustrates how to create a Master Detail report using grouping to organize the report.

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 an ActiveReport to a Visual Studio project

To add an ActiveReport to your project

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

Connecting the report to a data source

To connect the report 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, [order details], products where orders.OrderID = [order details].OrderID and products.productID = [order details].productID order by OrderDate".
  7. 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 your report.
  2. Make the following changes to the group header:
    • Change the name to ghOrders
    • Change the DataField property to Orders.OrderID
  3. Add the following controls to the GroupHeader section:

    Control DataField Name Text/Caption Misc Details Location
    Textbox OrderDate txtOrderDate Order Date (Empty string) 0, 0.25
    Textbox ShippedDate txtShippedDate Shipped Date (Empty string) 2.062, 0.25
    Label (Empty string) lblOrderDate Order Date (Empty string) 0, 0
    Label (Empty string) lblShipName Ship Name (Empty string) 1, 0
    Label (Empty string) lblShippedDate Shipped Date (Empty string) 2.062, 0
    Label (Empty string) lblFreight Freight (Empty string) 5.687, 0
    Textbox Freight txtFreight Freight OutputFormat = Currency 5.687, 0.25
    Textbox ShipName txtShipName Ship Name (Empty string) 1, 0.25
    Textbox ShipAddress txtShipAddress Ship Address (Empty string) 3.312, 0.25
    Textbox ShipCountry txtShipCountry Ship Country (Empty string) 4.437, 0.25
    Label (Empty string) lblShipAddress Ship Address (Empty string) 3.312, 0
    Label (Empty string) lblShipCountry Ship Country (Empty string) 4.437, 0
  4. Add the following controls to the Detail section:

    Control DataField Name Text/Caption Misc Details Location
    Label (Empty string) lblUnitPrice Unit Price (Empty string) 1.062, 0
    Label (Empty string) lblQuantity Quantity (Empty string) 4.25, 0
    Label (Empty string) lblDiscount Discount (Empty string) 5.25, 0
    Label (Empty string) lblOrderID Order ID (Empty string) 0.062, 0
    Label (Empty string) lblProductName Product Name (Empty string) 3.125, 0
    Textbox ProductName txtProductName Product Name (Empty string) 3.125, 0.187
    Textbox Quantity txtQuantity Quantity (Empty string) 4.25, 0.1875
    Textbox Discount txtDiscount Discount OutputFormat = Currency 5.25, 0.187
    Textbox orders.OrderID txtOrderID Order ID (Empty string) 0.0625, 0.1875
    Textbox products.UnitPrice txtUnitPrice Unit Price OutputFormat = Currency 1.0625, 0.1875
    Textbox products.ProductID txtProductID Product ID (Empty string) 2.062, 0.187
    Label (Empty string) lblProductID Product ID (Empty string) 2.062, 0

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.

Samples | Walkthroughs | OutputFormat Strings

 

 


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