0
votes

I am having an issue with a report I am working on. I am trying to set this report up so that when printed the duplex option is chosen and data is printed on the front and back properly. I already actually have this working when there are exact sets of 5 records being printed.

I have a 3 column by 2 row tablix. In cell A1 of that tablix I have another tablix which contains all the data that will print on the front side of the paper. In cell C3 of the outer tablix, I have an internal tablix that contains all of the data for the back side. Cells B2, B3, A1, and A2 are empty. Column B was created with the correct width to properly format for front and back so that the data would line up correctly.

My row group has an expression as such: =Ceiling(RowNumber(nothing)/5) which allows for the report to perfectly output the front data for the first 5 records on page 1, output the back data for the first 5 records on page 2, etc. as long as the number of records is a multiple of 5.

My problem is that when having odd numbers that are not multiples of 5 I can't get it to page break correctly. For instance, if there are 4 records remaining after the first group of 5, then the front side data prints for the first 4 records and then immediately on the same page without a page break it prints the back side data.

What can I do to get it to page break after those first 4 records and then output the back side data. Of course, this would need to work dynamically so that no matter if there were 4, 3, 2, or 1 records remaining it will page break after the first grouping.

I would greatly appreciate any assistance that can be provided. Thanks in advance!

1
How come you suddenly have 4 records? I'd understand this if it was the end of your data source but you have more records following afterwards. Are you splitting the datasource by grouping first and then adding the 5 record limit? Or do you use multiple datasources? It's quite confusing... Perhaps you could simply insert empty rows at the end of each group in your datasource to meet the 5 limit. using the group size and modulus 5 you'll know which reminder (rest) you have to add. - Oceans
Sorry if I confused you. For example, my data set has 9 records. The first 5 records display correctly with the front side of data on first page, and back side data on second page. Then the remaining 4 records have the first four front side data printed on the third page, but then the back side data for those four records continues on that third page. No page break occurs here. That is what I am trying to accomplish. Thanks for the response. - S. Costello

1 Answers

0
votes

If you always have this problem at the end of your report you could do the following to solve your issue. This probably isn't the most flexible solution but it'll get the job done.

Before sending the datasource/dataset to the reporter, simply determine the total amount of records. A DataSet exists out of one ore multiple DataTables, so this will vary depending on how yours is build, but with the following line you should be able to determine the total amount of records/rows.

var rCount = myDataSet.Tables[0].Rows.Count();

Now you can use this to calculate the amount of missing rows to top of your page-breaking correctly and add replacement rows with empty fields at the end of your datasource. Calculating the number of missing rows is done by taking the modulus of 5 (in your specific case) using the % operator in C#.
To add empty rows you must simply create empty objects so that nothing gets printed in the report. To assure this working flawlessly you might have to add expressions in the Tablix cells to catch any NULL values and replace them with empty strings.

for (int i = 0; i < rCount % 5; i++ )
{
    myDataSet.Tables[0].Rows.Add(new MyObjectClass());
}

If your DataSet happens to have multiple DataTables, simply do the same of the other tables.