views:

4426

answers:

3

I created a report as part of a C# application using Reporting Services and I cant find some functionality I am used to seeing in other environments. I believe both MS Access and Crystal reports have an option called "Keep Together" so that you can keep a specific grouping of data on one page instead of the information being split over two pages.

How do I do that using 2005 Reporting Services when my report is rendered locally in a C# app and viewed using the .net report viewer. Essentially, I want to keep all records for a certain year on one page. I am using Visual Studio 2008.

The year is one of the columns and the number of rows for one year is always smaller than a page. My report uses just one table and has an innermost grouping by year and then another outer grouping by client name.

Currently I can fit two years of data on the report, however, if the data starts half way through the first year, then I get the following:

Example:

Page one: 1/2 of 2004 because the data started half way through 04

All of 2005

First half of 2006

Page2: Second Half of 2006

What I would rather do is push all of 2006 to page two.

I am currently using a table for all of the data in the report. There is a keep together option at the Table level, but I need one at the Group level. In this case the Grouping by year.

Any help that can be provided will be much appreciated.

Thanks,

Jeremy

+1  A: 

Ok, what you need to do is to first define the reports page size to be large enough to encompass your entire data region.

See:

http://msdn.microsoft.com/en-us/library/bb677374.aspx

You then need to add Page Break Points to the Group in your Matrix. See below:

http://msdn.microsoft.com/en-us/library/ms156434.aspx

John Sansom
Thanks for the help. I updated my question to provide better information. The report page is already large enough to fit two years, but sometimes I get a full year and two partial years. Additionally, I am using a report table instead of a matrix. Perhaps I need to switch to a matrix. Thanks again.
JK
+1  A: 

Just to add a bit to John's answer. For SSRS 2005 the List and Table objects do have a KeepTogether property, which means they will try to keep everything on one page. I think the best approach is to follow John's advice first though.

Mozy
Thanks for the response. I found a Keep Together option at the table level, but not at the group level. Just for clarification, I am not using a matrix, I am using a table. Is there a keep together option at the grouping level in a table? – Thanks again.
JK
AFAK, there's not a KeepTogether property on a group. You will have to use page breaks and find ways to keep your data within the limits of your report page size (like John mentioned). For me in my environment formatting issues etc is the source of lots of frustration. :)
Mozy
Another thought to add to your example. If it were me I would probably group on the year and set the page break after the year group.
Mozy
I need to fit two years on one page and the page is already formatted large enough for two years.
JK
A: 

The problem was that I needed two years on a page and never 1/2 year even if the specific set of records started half way through the year. It turns out that even though there is a "Keep Together" option at the table level, there is not one at the group level. I needed this option at a group level. Instead of using a format solution I altered the underlying SQL for the report. In cases where there was only 1/2 year of data I created records for the other part of the year with correct dates, but zeros for all other values. This means that if the page is formatted properly to hold two years then it will always show two complete years and one year will never be broken over two pages. I also thought the answers provided by Mozy and John Sansom were good and I voted them both up.

Thanks for the help!

JK