1
votes

I'm trying to create a custom template report so that reports inheriting from it will use corporate standards for color and font. I want to create report variables for these, so that the same color can be employed in different parts of the report.

For instance, in the report header properties, I set the RGB values for the BackgroundColor property and, when I save my changes, I see a literal value in the property text box. If I then open the dropdown for the property again, and click the "Expression..." link, I see a numeric literal - in this case, #006a4d, which is a dark green. (I'm somewhat new to SSRS expressions, but apparently expressions that represent numeric constants don't require the "=" sign at the beginning.)

This tells me the constant representing the RGB combination that I want. Now, I go into the Variables tab of the Report Properties dialog and create a variable called "BckndClr" with the same hex constant as its value.

If I then go back to the BackgroundColor property and set it to the expression:

=Variables!BckndClr.Value

and save it, I find that, instead of continuing to to be dark green, the report header's background color in the Design tab has changed to the Auto default (white) color.

If The Visual Studio properties dialog displays a value for a literal color expression, why can't I use that same value in a user-defined variable and set the property expression to that variable?

1
I am not able to reproduce. Do you have #006a4d set as the VALUE property of the variable?user3056839
@user3056839 - Yes. It is the value. I'm using VS2012.Buggieboy
I think the key thing you mention is "in the Design tab..." The design tab does not execute the report. Variables and expressions are not evaluated when looking at the Design tab. Static items will generally render, but even there, it is very different from the Preview tab.Jamie F
Ahh, I wondered where the issue was - the op seemed to be describing the correct process. If you think about it, the value of variables and parameters is not necessarily known until the report is generated. It returns data sets, populates variables, then renders the report.user3056839
Yes. Per my reply to mmarie below, I was only looking at the design pallet.Buggieboy

1 Answers

3
votes

What you are calling the "literal color expression" (#006a4d) is the hex value of the color. You can use this website to convert your RGB values to hex. Not sure what version of SSRS you are using. I duplicated your steps in with SQL Server 2012 SP1 using SQL Server Data Tools for VS 2012.

  1. Created a variable in the report properties. Called it test. Pasted the hex value directly into the value box without clicking the expression button. enter image description here

  2. Went to the header properties, clicked on fill, and then clicked on the expression button next to the fill color. Enter =Variables!test.Value as the expression. Click OK. enter image description here

  3. Preview report. And verify the color of the header is dark green. enter image description here