none
Change Color of Textbox Depending on Value

    Question

  • He is my question depending on the code field from my database I need to display a different color. The field is a detail in my table with just text displaying the title of the report. I have the actual code value in another column. I then go to the background color expression and am using this code:

    =Iif(First(Fields!Code.Value, "CodeDataset") = 3, "Green", Iif(First(Fields!Code.Value, "CodeDataset") = 4, "Blue", "Red" )) 

    They all work if you pull the report up one at a time, but when selecting multi-values you get the color from the first record on each report page no matter what the second, third or so on values are. The code field does display each correct code. Is this being hard-coded to the first record?

    Wednesday, November 01, 2006 10:01 PM

Answers

  • if your statement:

    =Iif(First(Fields!Code.Value, "CodeDataset") = 3, "Green", Iif(First(Fields!Code.Value, "CodeDataset") = 4, "Blue", "Red" )) 

    You are evaluting the First Fields value "Literally" if you change it to

    =Iif(Fields!Code.Value= 3, "Green", Iif(Fields!Code.Value = 4, "Blue", "Red" ))  - red will be the default value I think you will see the proper results.

    Thursday, November 02, 2006 7:52 PM

All replies

  • Any Idea's ???
    Thursday, November 02, 2006 7:11 PM
  • if your statement:

    =Iif(First(Fields!Code.Value, "CodeDataset") = 3, "Green", Iif(First(Fields!Code.Value, "CodeDataset") = 4, "Blue", "Red" )) 

    You are evaluting the First Fields value "Literally" if you change it to

    =Iif(Fields!Code.Value= 3, "Green", Iif(Fields!Code.Value = 4, "Blue", "Red" ))  - red will be the default value I think you will see the proper results.

    Thursday, November 02, 2006 7:52 PM
  • Great thanks it was simple good I tried it with out the first,but I did still have the "DataSet" in there. What is first called is it a function so I can do some research. Also how do you do is null in an expression, and convert data types for a value? Thanks so much for your help!!!

     

    =Iif(Fields!Days.Value is Null, "AliceBlue", "White")

    Thursday, November 02, 2006 8:53 PM
  • I tried this code for my returntime field: Do I need to do a data conversion?

    =Iif(Fields!ReturnTime.Value <= 0, "AliceBlue", "Transparent")

     

    Build complete -- 0 errors, 0 warnings

    [rsRuntimeErrorInExpression] The BackgroundColor expression for the textbox ‘Days’ contains an error: Operator '<=' is not defined for type 'Date' and type 'Integer'.

    Preview complete -- 0 errors, 1 warnings

    Thursday, November 02, 2006 9:13 PM
  • Humm,

     

    I think its the "<=" should work try Fields!ReturnTime.Value < 0 or Fields!ReturnTime.Value = 0 instead.

    Friday, November 03, 2006 1:43 AM