Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
robert693
Starting Member
42 Posts |
Posted - 2013-04-21 : 16:59:02
|
Hello,Is there a way to call the value of the textbox with a function to change the background color in the fill property? 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? |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-04-21 : 17:52:30
|
quote: Originally posted by robert693 Hello,Is there a way to call the value of the textbox with a function to change the background color in the fill property? 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?
You should be able to set the Background Color property using an IIF expression. What is the expression you used? Can you post it? The IIF expressions would have to be nested though. An easier approach that I prefer instead of nesting may IIF's is to use the SWITCH construct like below:=Switch( Year(Fields!YourDateField.Value)=year(Today()),"Blue", Year(Fields!YourDateField.Value)=1+year(Today()),"Red", Year(Fields!YourDateField.Value)=2+year(Today()),"Green" ) |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-22 : 00:46:36
|
the value of textbox can be referred in SSRS using ReportItems!Textboxname.value------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
robert693
Starting Member
42 Posts |
Posted - 2013-04-22 : 08:38:21
|
The value of the textbox does not come from a field but is generated by the function above. There is a row of textboxes each of which have the month and year in sequence starting with the present month that a user generates the report and going up to 14 months out. I need for the months in the current year to be one color, the months in the next year to be another color and the months in the year after that to be another color. I need to know how to call the value of the textbox since there is no field that the data is drawn from. |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-04-22 : 09:11:02
|
Replace the Fields!YourDateField.Value in my example with the expression that you are using. Or, even better, use what Visakh suggested, i.e., use the ReportItems!Textboxname.Value. The Textboxname, obviously, is the name of the textbox where you have the value displayed. |
|
|
robert693
Starting Member
42 Posts |
Posted - 2013-04-22 : 09:45:54
|
Thank you for everybody's help! The Switch() worked with the "ReportItems!Textboxname.Value" calling the value of the textbox! |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-22 : 12:06:07
|
quote: Originally posted by robert693 Thank you for everybody's help! The Switch() worked with the "ReportItems!Textboxname.Value" calling the value of the textbox!
cool you're welcome ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|
|
|