Lesson 6: Adding a Parameter to Pass to a Drillthrough Report
New: 17 July 2006
Drillthrough reports are a type of report that you access by clicking a link in the current report. When you click on a text box with a drillthrough action, you open the drillthrough report. If the drillthrough report has parameters, you need to pass parameter values to each report parameter.
In this lesson, you will import the AdventureWorks sample report Sales Order Detail to your report server project and create a drillthrough action on the text box in the Sales Order report that contains the sales order number. You will set the drillthrough report parameter to be the sales order number, as expected by the drillthrough report. You will also create an internal parameter that defines the link color to use for the hyperlink text in the text box.
To import an existing report to your report server project
In Solution Explorer, right-click on the Report folder. Choose Add, and then Existing Item. The Add Existing Item dialog box opens.
Navigate to the folder where the AdventureWorks sample reports are installed. The default directory is <installdir>:\Program Files\Microsoft SQL Server\90\Samples\Reporting Services\Report Samples\AdventureWorks Sample Reports. Select Sales Order Details.rdl. The report is added to your report project.
You now need to bind your dataset data sources to your AdventureWorks database.
In Solution Explorer, double-click Sales Order Details.rdl.
Click the Data tab. The error "A connection cannot be made to the database" appears.
You need to modify the data source for the two datasets in this report to point to the AdventureWorks data source on your system.
From the Dataset drop-down list, select SalesOrder.
Click the Edit Dataset (…) button. The Dataset dialog box opens.
Next to the data source drop-down list, click the Edit Data source (…) button. The Data Source dialog box opens.
Verify that Type equals Microsoft SQL Server.
Click Edit next to the Connection String pane. The Connection Properties dialog box opens.
Enter the server name and authentication for your system. Stand-alone systems frequently use server name localhost and Windows authentication.
In the Connect to a database section, type AdventureWorks.
Click Test Connection. If you do not get a successful connection, contact your database administrator.
Repeat steps 5-13 for the SalesOrderDetail dataset.
Add a report drill through action to your report
In Solution Explorer, double-click Sales Order.rdl.
Click the Layout tab to change to Layout view.
In the Sales Order column, click in the detail row text box. The value in the text box should be
Right-click in the text box, and select Properties. The Textbox Properties dialog box opens.
Click the Navigation tab.
In the Hyperlink section, click Jump to report.
From the drop-down list in the text box, select Sales Order Detail.
Click the Parameters button. The Parameters dialog box opens.
From the Parameter Name drop-down list that shows the list of parameters defined for the drillthrough report, choose SalesOrderNumber.
Click in the Parameter Value text box. From the drop-down list, select
Next, change the text style and color for the drillthrough link.
Click the Font tab.
From the Decoration drop-down list, choose Underline.
In the Properties window for this text box, click in the Color property text box. From the drop-down list, choose Expression. The Expression Editor opens.
Replace the default text Black with the following expression:
The text box you added now has underlined text and will appear as the color set in the parameter MyFontColor. These visual indicators help report readers understand there is an active link to another report.
Before you can preview the report, you need to define the MyFontColor parameter in the next step.
To create an internal report parameter to use for Font Color
In Layout view, on the Report menu, click Report Parameters. The Report Parameters dialog box opens.
Click Add. A new parameter is created with property defaults set for you.
In the Properties section, in the Name property, type MyFontColor.
Verify the Data type is String.
Select the Hidden check box. The Prompt property is disabled.
Verify Available values is Non-queried.
In Default values, select Non-queried and type the value MediumBlue or any other valid font color.
To see valid values for font color, click the Foreground Color button on the Report Format toolbar.
Preview the report. Verify the sales order numbers appear underlined and with a different font color.
Click a sales order number. The Sales Order Detail report for that sales order number opens.
If you have made changes to the detail report but continue to get an error when you click the drillthrough link in the main report, the data cached for the report might need to be refreshed. Report Designer caches query results on the client in an Rdl.data file to improve performance. To refresh the local cache, change the query in Report Designer by adding a space, and click Preview.
In this lesson, you have successfully imported an existing report and rebound its data sources. You have added a parameterized drillthrough link in the main report to the imported report and created an internal parameter to define a drillthrough link color. This completes the Adding Parameters to a Basic Tabular Report tutorial. For more tutorials that use parameters, see Tutorial: Advanced Features Using Parameters.