ActiveReports 6 Online Help
Hyperlinks and Drill Down Sample

This sample consists of three reports and a ViewerForm. The reports use the Hyperlink event of the viewer to pass a value from the Hyperlink property of a TextBox control to a Parameter value in a more detailed report.

ViewerForm

This form contains only an ActiveReports Viewer control with its Dock property set to Fill. This ensures that the viewer resizes along with the form at run time.

Right-click the form and select View Code to see the code that allows multiple ViewerForms to display, and see the Form Load event for the code that loads the main report into the viewer.

See the Viewer Hyperlink event for the code that collects a string value from the Hyperlink property of the clicked TextBox on the main report and passes it into the customerID Parameter of the report DrillDown1, or collects a numeric value and passes it to the orderID Parameter of the report DrillDown2. This code then runs the report with the parameter value and displays it in another instance of the ViewerForm.

DrillDownMain Report

The main report that is loaded in the ViewerForm by default uses the PageHeader and Detail sections.

PageHeader Section

This section contains three Label controls to serve as column headers for the details, and a CrossSectionBox control. For more information, see Cross Section Controls.

Detail Section

The Detail section has its BackColor property set to Thistle, and its RepeatToFill property set to True. This ensures that the background color reaches all the way to the bottom of the page when there is not enough data to fill it.

Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the Connection String and SQL Query that provide data for the bound fields.

The Detail section has three bound TextBox controls that display a list of customer information. Select CustomerID and you will see that the HyperLink property is not set in the Properties window. To see the code that assigns the data from the TextBox to its HyperLink property, right-click the report and select View Code.

The HyperLink property is set in the Detail BeforePrint event. For more information, see Section Events.

Note: This hyperlink does not work in Preview mode, because it relies on code in the ViewerForm to pass the value to DrillDown1 report's parameter.

PageFooter Section

This section is not in use, so it is hidden by setting the Visible property to False. This section cannot be deleted, because its related PageHeader section is in use.

DrillDown1 Report

This report looks similar to the DrillDownMain report, but the main difference is that it has a CustomerID parameter in its SQL Query.

GroupHeader Section

Since this report only displays order information for the CustomerID from the clicked hyperlink, the PageHeader section could have been used, but this report uses the GroupHeader section. To make this section print at the top of each page, its RepeatStyle property is set to OnPage.

Like in the previous report, this section contains three Label controls to serve as column headers for the details, and a CrossSectionBox control.

Detail Section

Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the parameter in the  SQL Query that collects its value from the ViewerForm.

Parameters in SQL Queries are denoted by the <% and %> symbols that trigger ActiveReports to add them to the report's Parameters collection. For more information, see Parameters.

The Detail section has five bound TextBox controls that display a list of order information for the customer. Select OrderID and you will see that the HyperLink property is not set in the Properties window. To see the code that assigns the data from the TextBox to its HyperLink property, right-click the report and select View Code.

The HyperLink property is set in the Detail BeforePrint event. For more information, see Section Events.

GroupFooter Section

This section is not in use, so it is hidden by setting the Visible property to False. This section cannot be deleted, because its related GroupHeader section is in use.

DrillDown2 Report

Like DrillDown1, this report has a parameter in its SQL Query, but unlike the other two reports, this one has no hyperlink. It displays order details for the OrderID value passed into it from the clicked hyperlink in DrillDown1.

GroupHeader Section

Like in the previous report, this section contains Label controls to serve as column headers for the details, and a CrossSectionBox control.

Detail Section

Click the gray report DataSource icon on the Detail section band to open the Report Data Source dialog, where you can see the parameter in the  SQL Query that collects its value from the ViewerForm.

See Also

Walkthroughs