Textbox fill color based on textbox value

  • Hello,

    I have a report with a series of textboxes. The value of the textboxes is based on the month and year in regards to the present. Each has a function in the value, the first textbox has: =MonthName(Month(Now()))&" "&Year(Now()) and gives the present month and year. Each of the following textboxes has a function similiar to: =MonthName(Month(DateAdd(DateInterval.Month, 1, now())))&" "& Year(DateAdd(DateInterval.Month, 1, now())) increasing the number of months up to 14 months in the future, i.e. April 2013, May 2013 etc.. For each textbox I would like to have the fill color based on the year shown in the value. For this year it would be blue, for next year it would be red, and for two years in the future, it would be green. I tried to do this with IIF() functions and other ways but it does not work Is there a way to do this?

  • not an SSRS expert, but i certainly know html and css.

    if you can set the class of each option in the select list, you can do it:

    a css example:

    http://stackoverflow.com/questions/2720532/html-select-dropdown-list-with-multiple-colours

    and here is a SRS specific link to the one post on how to do it:

    http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/8cbbcb82-0f97-438a-831f-0f5ae6d6b85c/

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • There is no way to call the value of the textbox with a function to change the background color in the fill property?

  • Using the IIF statement should work for you. The expression for BackgroundColor is the one to use. A value something like the following should work

    =IIF(Fields!Year.Value = Year(Now()), "Green", IIF(Fields!Year.Value = Year(Now()) + 1, "Yellow", "Red"))

  • Thank you for your help but the value of the textbox comes from a function, not any field. For example, the textbox that will have the month and year four months ahead is =MonthName(Month(DateAdd(DateInterval.Month, 4, now())))&" "&Year(DateAdd(DateInterval.Month, 4, now())). I don't know how to call just the value of the textbox.

  • You can use Reportitem.TextBox1.value to get the value of the text box(named textbox1) then use it a IIF expression like Happy cat suggested.

    alternatively you could take your formula that you use in the the text box and make it into a calculated field then use that in the IIF expression.

  • Thank you!

Viewing 7 posts - 1 through 6 (of 6 total)

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