locked
Dynamically Set Subreport Background Color to the Same Value as Main Report Background Color RRS feed

  • Question

  • I have a report that contains a subreport.  The main report has groupings in it.  I am dynamically setting the background color of the group rows based on an expression.  That part is working fine.  The problem that I am having is that I don't know how to get the subreport to "inherit" the background color of the grouping that holds it.

    Basically, I have different row shadings on my report differentiating the groupings except for the rows where the subreport shows.

    How do I go about setting the subreport background color to equal it's contaiing grouping's background color?  Thanks in advance for any and all assistance provided.

    Monday, January 27, 2014 3:14 PM

Answers

  • Could you please try this 

    a) create a parameter "color"( name should be same in both the reports) both in subreport and main report. 

    b) pass color value in main report as color group expression (or hard code color name e.g. "red" for testing ).

    c) write dynamic expression for  background color in subreport like "Parameters!color.Value" 

    It should work. for passing parameters you can get more details in link .


    Gaur


    • Edited by gpshukla Monday, January 27, 2014 4:17 PM Edited
    • Proposed as answer by Alisa Tang Tuesday, January 28, 2014 1:54 AM
    • Marked as answer by Alisa Tang Friday, January 31, 2014 8:46 AM
    Monday, January 27, 2014 4:14 PM
  • The parameter method given by gpshukla will send the info to the subreport, but you don't need the color parameter in the main report, only the subreport. The trick is in setting the value of that parameter.

    1. Right-click the cell with the embedded subreport, you can select subreport properties.
    2. Select Parameters and add a parameter.
      The name column is the name of the parameter in the subreport (color) and value is the value to set it to.
    3. Set name to "color" (no quotes).
    4. Set Value to the same expression used to set the background color for the row.
    5. In the subreport, click the design surface to select the report (not header or footer).
    6. In the properties pane, select background color and choose expression from the dropdown.
    7. Type =Parameters!color.Value into the expression builder.

    This will work assuming that background color in the main report row will not change without also refreshing the subreport.


    "You will find a fortune, though it will not be the one you seek." - Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

    • Proposed as answer by Alisa Tang Tuesday, January 28, 2014 1:54 AM
    • Marked as answer by Alisa Tang Friday, January 31, 2014 8:46 AM
    Monday, January 27, 2014 5:40 PM

All replies

  • Could you please try this 

    a) create a parameter "color"( name should be same in both the reports) both in subreport and main report. 

    b) pass color value in main report as color group expression (or hard code color name e.g. "red" for testing ).

    c) write dynamic expression for  background color in subreport like "Parameters!color.Value" 

    It should work. for passing parameters you can get more details in link .


    Gaur


    • Edited by gpshukla Monday, January 27, 2014 4:17 PM Edited
    • Proposed as answer by Alisa Tang Tuesday, January 28, 2014 1:54 AM
    • Marked as answer by Alisa Tang Friday, January 31, 2014 8:46 AM
    Monday, January 27, 2014 4:14 PM
  • The parameter method given by gpshukla will send the info to the subreport, but you don't need the color parameter in the main report, only the subreport. The trick is in setting the value of that parameter.

    1. Right-click the cell with the embedded subreport, you can select subreport properties.
    2. Select Parameters and add a parameter.
      The name column is the name of the parameter in the subreport (color) and value is the value to set it to.
    3. Set name to "color" (no quotes).
    4. Set Value to the same expression used to set the background color for the row.
    5. In the subreport, click the design surface to select the report (not header or footer).
    6. In the properties pane, select background color and choose expression from the dropdown.
    7. Type =Parameters!color.Value into the expression builder.

    This will work assuming that background color in the main report row will not change without also refreshing the subreport.


    "You will find a fortune, though it will not be the one you seek." - Blind Seer, O Brother Where Art Thou
    Please Mark posts as answers or helpful so that others may find the fortune they seek.

    • Proposed as answer by Alisa Tang Tuesday, January 28, 2014 1:54 AM
    • Marked as answer by Alisa Tang Friday, January 31, 2014 8:46 AM
    Monday, January 27, 2014 5:40 PM