Mark
Mark

Reputation: 4950

SSRS report - find tablix currently being rendered

I am trying to solve the following problem. I have two tablix in my report. Each has its own dataset. I want to show different messages in the footer based on a tablix being rendered. Each table might take a different number of pages. Any idea? I am specifically targeting Word export. What was suggested in Alan's respond is not working for the Word export.

Thanks

Upvotes: 0

Views: 169

Answers (1)

Alan Schofield
Alan Schofield

Reputation: 21683

If I've understood your question correctly, you can do this with a report variable and a textbox.

Below is the layout I used. I've coloured some areas just for clarity.

enter image description here

The two tables contain sample 'people' and sample 'addresses', these are the labels I will show in the footer of the respective pages.

First you need to add a report variable, so right-click a blank area of the report body and choose "Report Properties", Click the "Variables" tab and add anew new Variable called LastTablix, set it's Value to whatever you want on your first footer to be, in my case "People". Make Sure you UNCHECK the Read-Only option

enter image description here

Now add a footer to your report (yellow in my example) and add a textbox to the footer (green in my example).

Set the expression of the textbox to

=Variables!LastTablix.Value 

Make sure the name is spelled correctly, it's case sensitive.

If you run the report now, you will see "People" on each footer, now we just need a way to change it.

Next, add a new text box (red in example). Set the expression of this textbox to

=Variables!LastTablix.SetValue("Addresses")

Next, on the second tablix, set the PageBreak/BreakLocation to Start

If you run the report now, you should see the footer change to the text in the expression above.

Now you just need to make the red textbox as small as you can, set the background and font colours to nothing/white and that should be that. Note: you cannot set the textbox to Hidden=True as the textbox will not be rendered and the expression to update the variable will not execute.

Upvotes: 1

Related Questions