Question

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?

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top