Archive for July, 2007

Dynamic Report Formatting

Monday, July 23rd, 2007

Formatting your report based on the user or the data is relatively straight forward once you get the trick. To demonstrate, create a report with a valid connection to an instance of Microsoft SQL Server and use the following SQL as your query:

SELECT
    CASE @param
        WHEN 0 THEN 'Blue'
        WHEN 1 THEN 'Red'
    END AS color,
    CASE @param
        WHEN 0 THEN '12pt'
        WHEN 1 THEN '24pt'
    END AS size

and create five text boxes with the following attributes:
TextBox1
Value: Color
Color: =First(Fields!color.Value)

TextBox2
Value: Size
Font: Normal, Arial, =First(Fields!size.Value), Normal

TextBox3
Value: Both
Color: =First(Fields!color.Value)
Font: Normal, Arial, =First(Fields!size.Value), Normal

TextBox4
Value: =First(Fields!color.Value)

TextBox5
Value: =First(Fields!size.Value)

and then run the report. When you run your report you should see something like the following:

Adding a Link to Another Report With Parameters

Sunday, July 8th, 2007

Reporting services allows you to add a navigation property to a text box, allowing you to provide links to other content. If you are linking to another report, there is even a method of passing parameters into it. Here are the steps to link from one report to another using parameters on the links:

  1. Right click on a text box and choose [Properties] from the context menu.

  2. Choose the [Navigation] tab on the Properties Window.

  3. Choose the [Jump to report:] Hyperlink action and choose the report you want to jump to.
  4. Click on the [Parameters…] button in the Hyperlink action section.
  5. Under [Parameter Name], choose one of the parameters for the report. If the report does not take parameters, you will not be given any choices.

  6. Under Parameter Value, choose either a value or [Expression…]. Note that the last parameter listed is an aggregate.

If you don’t have access to the values you are looking for, you may have to add your text box to an iterator of some sort. List is the most basic, so here is what you can do:

  1. Add a List to your report.
  2. Set the dataset for the list on the [List Properties][General] tab.

  3. Move your text box into the List.
  4. Under Parameter Value, choose either a value or [Expression…]. Note that this time you have access to the actual Field and not just an aggregate.