SQL Server 2000 Reporting Services Bug?: Rectangle Visibility
For the last couple of weeks I have been building a SQL Server 2000 Reporting Services report for a client. The input to the report is a series of rows from the database. Each row could have two different types of data; for this blog I will call the two types of data, Alpha and Omega. A row will either contain Alpha data, Omega data, or both. The requirements state that the section of the report dealing with the Alpha or Omega data should only appear when that data appears in the input data row. Both Alpha and Omega data have one other characteristics that is of interest for this blog: The data could be complete or incomplete. When the data is complete, the output report should contain three pages of output. When the data is incomplete, the output report should contain two pages (the third page is omitted).
The first design decision was to use a List report item to hold the report output. The list item can hold multiple lines of data from the same row.
The next design decision was to define two rectangles within the List report item, one for the Alpha data and one for the Omega data. The rectangle has a "visibility hidden" property that controls whether the report item is displayed or not. If the report item is not displayed, the space that would be used to display the data is collapsed. One thing to note is that the "hidden" property can be set to "true", "false" (the default), and to an expression. Oddly enough, reporting services acts differently when the expression is used, even if the computed expression returns a constant equal to true or false.
The third design decision was to create a rectangle for each page of each report. Thus, we have Alpha 1, Alpha 2, Alpha 3, Omega 1, Omega 2, and Omega 3. The Alpha 1, 2, and 3 rectangles are children of the Alpha report rectangle. The Omega 1, 2, and 3 rectangles are children of the Omega report rectangle. The Alpha 3 and Omega 3 rectangles each have an expression to control whether they are visible within their respective report rectangles.
All of this works just fine when I use Reporting Services 2005. The problem comes when using the 2000 version (which is what the client is using): The report items for the optional third pages are not displayed but the space for the report items is not collapsed (that is, we get blank pages). This is not goodness.
I have tracked the problem down to the use of expressions to control visibility for nested rectangles. I solved the problem by eliminating the two "report" rectangles, thus bringing each of the "page" rectangles up to the top level within the List report item. I had to distribute the "Is Alpha" and "Is Omega" expressions to the "hidden" property of each page and double up the expression for the two optional pages: "Is Alpha and Is Complete Alpha".
There may be some other things going on here and there may be another way to solve this but this approach solves my problem. Perhaps it will solve your problem as well.
Jon Stonecash is a technology consultant and has been designing, developing, and testing various kinds of software for such a long time that he has had the opportunity to make most of the serious software development mistakes at least once. His long term interests center about databases and the aspects of the application that handle data access and business logic. He is also interested in the tools that assist the development process, particularly code generation.