Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Textbox fill color based on textbox value Expand / Collapse
Author
Message
Posted Friday, April 19, 2013 2:26 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 11, 2013 12:14 PM
Points: 19, Visits: 50
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?
Post #1444606
Posted Friday, April 19, 2013 2:43 PM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 9:35 AM
Points: 12,965, Visits: 32,525
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

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1444613
Posted Sunday, April 21, 2013 8:20 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 11, 2013 12:14 PM
Points: 19, Visits: 50
There is no way to call the value of the textbox with a function to change the background color in the fill property?
Post #1444797
Posted Sunday, April 21, 2013 10:53 PM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Thursday, December 4, 2014 7:54 PM
Points: 3,087, Visits: 2,686
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"))



Post #1444851
Posted Monday, April 22, 2013 6:31 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 11, 2013 12:14 PM
Points: 19, Visits: 50
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.
Post #1444947
Posted Monday, April 22, 2013 7:12 AM
SSChasing Mays

SSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing MaysSSChasing Mays

Group: General Forum Members
Last Login: Friday, December 19, 2014 9:37 AM
Points: 612, Visits: 2,146
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.
Post #1444972
Posted Monday, April 22, 2013 8:41 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Friday, October 11, 2013 12:14 PM
Points: 19, Visits: 50
Thank you!
Post #1445013
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse