As I work through converting Crystal Reports to SSRS reports at times I amazed at some of the functionality that is not yet available. We have been using Crystal to create several different types sales documents. The easiest way I have found to create Sales Document type reports is with a header/ detail type of scenario. You can pull the header information for the Sales Document and group on the document number. Then you add page breaks between each instance. To account for multiple line items that will most likely be on sales documents add a sub report for the line items. simple enough. Then the request for page numbers comes along. Seems reasonable that you would like to have page 1, 2, 3 on a sales document, but in this situation the page numbers would be based on the entire report not on the grouped items. So if a sales document is three pages long OOB Report Projects or Report Builder will not just allow you to add the pages numbers for the grouped items.
Now for the solution.
When in the design mode of Report Builder or Visual Studio select Report >Code
Here is my code:
Shared groupName as Object Shared PageNum as Object Public Function GetPageNumber(group as Object) as Object If (group = groupName) PageNum =PageNum +1 else PageNum = 1 End If Return PageNum End Function
You will set two variables to store the values behind the scenes.
Then in your function you will pass in the name of the group you are on by passing the value you are grouping on into the function. Then if the group matches the one that is stored the page number increments and if it does not it takes it back to 1.
Then on the report where you would like to add the page number add a textbox. Add an expression to the textbox that calls the GetPageNumber function. You will pass in the ReportItem field you are using to create the group
Just an fyi on any custom code I add to the code tab has a redline when I try to call it in the expression. Do worry. It will still work.
This is a fairly simple approach to solving this problem.
Comment me if you have any problems.