Dynamically render color AND decoration of BOLD

  • I'm using the following line of code on my RS 2005 report textbox properties to render the color Black or Red depending on the value of the column. If the value of the cell is "Prod", the color rendered is red --- else it's black:

    =IIf(UCase(RTrim(Fields!EnvName.Value)) = UCase("Prod") ,"RED", "BLACK")

    How can I render the additional attribute of BOLD when the color is Red? (I do NOT want the cell to be BOLD when the value <> "Prod")

    thanks in advance.

    BT
  • Simple really, you already have the code to do it, just go to the Font Style area of the same properties and add the expression:

    =IIf(UCase(RTrim(Fields!EnvName.Value)) = UCase("Prod") ,"Bold", "Normal")

    Good luck,

    Nigel West
    UK

  • Nigel - thanks - that worked great. 1 more question ----

    Is it possible to test the cell value for multiple values -- and depending on the value, set the color, weight, etc?

    For example --

    if the value is "Prod" I'd like to see it displayed BLUE, BOLD

    if the value is "QA" I'd like to see it displayed RED, NORMAL

    if the value is "Test" I'd like to see it displayed ORANGE, NORMAL

    thx in advance

    BT
  • Yes, and these work basically the same way as an excel IF...THEN...IF...THEN..ELSE statement.

    if the value is "Prod" I'd like to see it displayed BLUE, BOLD

    if the value is "QA" I'd like to see it displayed RED, NORMAL

    if the value is "Test" I'd like to see it displayed ORANGE, NORMAL

    This would be something like:

    =IIF(Fields!FieldName.Value="Prod","BLUE",

    IIF(Fields!FieldName.Value="QA","Red",

    IIF(Fields!FieldName.Value="COMP","YELLOW",

    "BLACK")))

    Notice that the final closing brackets must close ALL opening brackets.

    Same syntax obviously applies to any expression.

    Nigel West
    UK

  • Sorry, I am sure you've guessed, but BLACK is the final ELSE part of the expression.

    Also, make sure the case is correct for the colours, not all uppercase like I've put in the example.

    Nigel West
    UK

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply