ActiveReports 6 Online Help
Hyperlinks for Simulated Drill-Down Reporting
Show AllShow All
Hide AllHide All

Hyperlinks can be used in ActiveReports to pass values to parameters in other reports. This walkthrough illustrates how to set up hyperlinks in a report to simulate drill-down reporting.

This walkthrough is split up into the following activities:

Tip: For basic steps like adding a report to a Visual Studio project and viewing a report, please see the Basic Data Bound Reports walkthrough.

To complete the walkthrough, you must have access to the Northwind database.
A copy is located at C:\Program Files\GrapeCity\ActiveReports 6\Data\NWIND.MDB (on a 64-bit Windows operating system, a copy is located in C:\Program Files (x86)\GrapeCity\ActiveReports 6\Data\NWIND.MDB).

When you have finished this walkthrough, you will have reports that look similar to the following.

To connect three reports to data sources

  1. Add three reports to a Visual Studio project, naming them rptCustomers, rptOrders, and rptProductDetails.
  2. On rptCustomers, click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog.
  3. On the OLE DB tab, next to Connection String, click the Build button.
  4. In the Data Link Properties window that appears, select Microsoft Jet 4.0 OLE DB Provider and click the Next button.
  5. Click the ellipsis (...) button to browse to the Northwind database. Click Open once you have selected the appropriate access path.
  6. Click OK to close the window and fill in the Connection String field.
  7. In the Query field, enter the following SQL query
    SQL Query
    Copy Code
    SELECT CompanyName, ContactName, Phone, CustomerID FROM Customers ORDER BY CustomerID
  8. Click OK to save the data source and return to the report design surface.
  9. On rptOrders, click the gray report DataSource icon on the Detail section band and connect it to Nwind.mdb.
  10. In the Query field, enter the following SQL query
    SQL Query
    Copy Code
    SELECT Orders.OrderID, Orders.CustomerID, Orders.OrderDate, Orders.ShippedDate, [Order Details].ProductID, 
    Products.ProductName, [Order Details].UnitPrice, [Order Details].Quantity, [Order Details].Discount
    FROM Products INNER JOIN (Orders INNER JOIN [Order Details] ON Orders.OrderID = [Order Details].OrderID) 
    ON Products.ProductID = [Order Details].ProductID
    WHERE Orders.CustomerID = '<%CustomerID||ALFKI%>'
    ORDER BY Orders.OrderID, Products.ProductName
    
  11. Click OK to save the data source and return to the report design surface.
    Note: The SQL queries for rptOrders and rptProductDetails use parameters syntax: '<%CustomerID||ALFKI%>' and <%ProductID||1%>. Using a default value allows the Report Explorer to populate so you can drag fields onto the report. For more information on parameters, see the Parameters topic.
  12. On rptProductDetails, click the gray report DataSource icon on the Detail section band and connect it to Nwind.mdb.
  13. In the Query field, enter the following SQL query
    SQL Query
    Copy Code
    SELECT Products.ProductID, Products.ProductName, Suppliers.CompanyName, Categories.CategoryName, Products.QuantityPerUnit, 
    Products.UnitPrice, Products.UnitsInStock, Products.UnitsOnOrder, Products.ReorderLevel, Products.Discontinued
    FROM Categories 
    INNER JOIN (Suppliers INNER JOIN Products ON Suppliers.SupplierID = Products.SupplierID) 
    ON Categories.CategoryID = Products.CategoryID
    WHERE Products.ProductID = <%ProductID||1%>
    
  14. Click OK to save the data source and return to the report design surface.

To format the reports and add controls to display data

Top-level Report: rptCustomers

  1. In the design view of rptCustomers, click to select the page header section, and in the Properties Window, change the following properties:
    • BackColor: Gainsboro
    • Height: 0.5
  2. Select the detail section, and set its properties as follows:
    • BackColor: GhostWhite
    • CanShrink: True
  3. Add the following controls to the indicated sections rptCustomers, setting their properties as indicated:

    rptCustomers controls

Mid-level Report: rptOrders

  1. In the design view of rptOrders, click to select the page header section, and set its Height property to 0.5.
  2. Add the following controls to the page header section, setting their properties as indicated:

    Page header controls for rptOrders

  3. Right-click the report and select Insert, then GroupHeader/Footer.
  4. Set the group header properties as follows:
    • BackColor: LightCyan
    • DataField: OrderID
    • Height: 0.5
  5. Add the following controls to the group header section, setting their properties as indicated:

    Group header controls for rptOrders

  6. Click in the grey area below the report to select it, and set the ShowParameterUI property to False to avoid requesting parameters from the user.
  7. Select the detail section, and set its CanShrink property to True.
  8. From the Report Explorer, drag the following fields onto the detail section of rptOrders, setting their properties as indicated:

    Detail section controls for rptOrders

Lowest-Level Report: rptProductDetails

  1. Add a textbox to the page header section of rptProductDetails, setting its properties as indicated:

    rptProductDetails controls

  2. Add the following labels to the detail section, setting their properties as indicated:

    rptProductDetails labels

  3. From the Report Explorer, drag the following fields onto the detail section, setting their properties as indicated:

    rptProductDetails fields

To add code to the viewer form for special hyperlink functions

This walkthrough assumes that you already know how to display a report in the viewer. For more information about these basic functions, see the Viewing Reports topic.

To write the code in Visual Basic

To write the code in C#

To add code to set the drill-down hyperlink in rptCustomers

  1. Double-click in the detail section to create a detail_Format event.
  2. Add code to the event to set the hyperlink of the Customer ID textbox to call the viewer code that passes the parameter to rptOrders.

To write the code in Visual Basic.NET

To write the code in C#

To add code to set the drill-down hyperlink in rptOrders

  1. Double-click in the detail section to create a detail_Format event.
  2. Add code to the event to set the hyperlink of the Product ID textbox to call the viewer code that passes the parameter to rptProductDetails.

To write the code in Visual Basic.NET

To write the code in C#

To add code to create a parameter to hold the previous report for rptProductDetails

  1. Right-click the report and select View Code.
  2. Add code to create a parameter for the previous report.

To write the code in Visual Basic.NET

To write the code in C#

To add code to set the hyperlink to return to rptOrders in rptProductDetails

  1. Double-click in the detail section to create a detail_Format event.
  2. Add code to the event to set the hyperlink of the Return to Orders textbox to call the code that passes the parameter to rptOrders.

To write the code in Visual Basic.NET

To write the code in C#

See Also

How To

Concepts