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.

 All Forums
 SQL Server 2005 Forums
 Analysis Server and Reporting Services (2005)
 Variable Background Color

Author  Topic 

stevenc49
Starting Member

14 Posts

Posted - 2008-07-15 : 19:00:46
Is there a way I can set the background color of a textbox field based on some data field variable?

For example:

-if datafieldvalue=1, the background color of the textbox should be yellow.
-if datafieldvalue=2, the background color of the textbox should be green.

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-07-15 : 19:23:12
Put something like this as an expression in the "BackgroundColor" property:
=iif(Fields!job_no.Value="1","Yellow","Blue")
In order to access the field, you need to have your textbox on a list or table which has the data set attached to it.
Go to Top of Page

stevenc49
Starting Member

14 Posts

Posted - 2008-07-15 : 19:28:43
Thanks, I got it to display 2 different colors.
But is there a way to choose between 3 different colors?

I tried multiple if statements:

=iif(Fields!issuetype.Value=1, "Purple", "Yellow")
=iif(Fields!issuetype.Value=3, "Green", "Yellow")

but it seems to only use the bottom one.
Go to Top of Page

stevenc49
Starting Member

14 Posts

Posted - 2008-07-15 : 19:48:58
Found a solution for anyone who is interested:

=iif(Fields!issuetype.Value=1, "BlueViolet", iif(Fields!issuetype.Value=3, "Green", "Yellow"))
Go to Top of Page

dexter.knudson
Constraint Violating Yak Guru

260 Posts

Posted - 2008-07-16 : 01:10:45
Another way of doing this is:
=SWITCH(Fields!issuetype.Value=1, "Purple",
Fields!issuetype.Value=2, "Green",
Fields!issuetype.Value=3, "Yellow",
)
Go to Top of Page
   

- Advertisement -