Please note that I have posted a new blog for this subject here. /Claus Lundstrøm
In our Classic reports we have the possibility to use Transfooter and Transheader. A typical use for classic Transfooters and Transheaders are to show a current subtotals up to the end of the current page or sums per page
These functions are not directly mapped from Classic reports to RDLC reports in Dynamics NAV 2009, but in this post I will go through how this is done in RDLC reports:
1. Create new report blank report with table 18
2. Create DataItem ”Customer”
3. Go to Section Designer and add the following fields:
· Debit Amount
4. Save the report as ID 50000 – Transfooter / Transheader
5. Now go to Visual Studio (View / Layout)
6. Create table and add the fields No, Name and Debit Amount
7. Give this table the name “MainTable”
8. Now we have added the basic for this report. But I would also like to have a Grand total of the Debit Amount so I add this as well. I add this in the Footer of the table
="GrandTotal: " & sum(Fields!Customer__Debit_Amount_.Value)
9. Now if my report is printed I get a list of my all my customer with Debit Amount displayed and with GrandTotal in the end of the report:
10. Now I would like to see the accumulated sum of the Debit Amount on each the page footers, and on the next page display this accumulated sum from previous page. So I will add Transfooter and Transheader functionality to the report.
11. First we need to do some intermediate calculations to accomplish this.
Add 3 new columns to the existing table in Visual Studio;
12. In the first column enter this expression:
=RunningValue(Fields!Customer__Debit_Amount_.Value, Sum, "MainTable")
And give this name “Subtotals1”
13. In the Second column enter this expression:
=RunningValue(Fields!Customer__Debit_Amount_.Value, Sum, "MainTable") - Fields!Customer__Debit_Amount_.Value
And give this name “Subtotals2”
14. In the Third column enter this expression:
=RunningValue(Fields!Customer__No__.Value, Count, "MainTable")
And give this name “SubCount”
The 3 columns should now look like this:
15. As these 3 columns are only used for calculation I will make them really small and set Visibility “Hidden=True” and make the font red so I remember that these columns are hidden.
Your report should now look like this:
16. Ok, it’s now time to add a Transfooter and Transheader. Enable Page Header and Page Footer in the report. You report should look like this:
17. In the Page Footer I place a text box with the following expression:
="Transfooter subtotal = " & Last(ReportItems!Subtotals1.Value)
And then I set BackgroundColor, and Color just so this Transfooter stands out in my report, and right align text:
18. In the Page header I place a text box with the following expression:
="Transheader subtotal = " & (First(ReportItems!Subtotals2.Value))
19. Now I’m almost done but I would like to not see the Transheader on the first page and not to see the Transfooter on the last page, so I select properties on the Page Header and set the “PrintOnFirstPage=False”
20. Now I could do the same on Page Footer, but maybe I would like to display the Page Footer, but not with the Transfooter displayed, so here is a little trick for how to do this.
21. Insert a text box below the table and set the expression to “=True”, Name=LastPageControl, Hidden=True and color red.
22. With this field added after the table we can now check to see when we are on the last page.
So I add the following Visibility Expression on the Transfooter textbox:
23. Now I’m done, I save, import into NAV and compile. After some fit and finish on the report it now looks like this when I print:
You can download my report here as FOB and XPS.
Thanks, Claus Lundstrøm, Program Manager, Microsoft Dynamics NAV
Please explain why you need the SubCount column with the expression: =RunningValue(Fields!Customer__No__.Value, Count, "MainTable")
This is fine unless you use BlankZero() function generated by Dynamics NAV reporting tool in RDLC. If the value is blank instead of zero. It show #error in that control.
So my question is how to solve this problem.
We have problem with empty space on the first page (reserved for the header, which is not printed). This is known bug. Have you different solution usable in case when the transheader is bigger than one line? (one line go through first page unnoticed, but header bigger will create visible empty space). This bug is not there when rendering to HTML...