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 |
jamie
Aged Yak Warrior
542 Posts |
Posted - 2009-11-16 : 10:54:49
|
hi,I am trying to change the colour of text boxes depending on the values in them.I have 2 textboxes , If textbox 1 contains a larger number than textbox 2 then I want the background to be green, if it is lower then the colour should be red, and if the numbers are the same then orange.I have the below code but sometimes the text box is showing the incorrect colour..=IIF(format(((SUM(Fields!M_1_Tasks.Value)/ CDec(SUM(Fields!M_1_secs_worked.Value)))*60*60),"N0") < format(((SUM(Fields!M_2_Tasks.Value)/ CDec(SUM(Fields!M_2_secs_worked.Value)))*60*60) ,"N0") , "Red", IIF(format(((SUM(Fields!M_1_Tasks.Value)/ CDec(SUM(Fields!M_1_secs_worked.Value)))*60*60),"N0") > format(((SUM(Fields!M_2_Tasks.Value)/ CDec(SUM(Fields!M_2_secs_worked.Value)))*60*60),"N0"), "Green", IIF(format(((SUM(Fields!M_1_Tasks.Value)/ CDec(SUM(Fields!M_1_secs_worked.Value)))*60*60),"N0") = format(((SUM(Fields!M_2_Tasks.Value)/ CDec(SUM(Fields!M_2_secs_worked.Value)))*60*60),"N0"), "Orange", "Orange")))I think the problem could be the formatting, eg. sometimes no number exists. what am I doing wrong?thank you for any help. |
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2009-11-16 : 11:47:12
|
how can I simplify this to sometihng like :IIF (Textbox1 < Textbox2 , "Red", IIF(Textbox1>Textbox2, "Green", "Orange")) ? |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2009-11-16 : 12:08:24
|
hi,so I have worked it out using :=IIF( Format(cint(ReportItems!textbox125.Value),"N0") < Format(cint(ReportItems!textbox126.Value),"N0") , "Red",IIF( Format(cint(ReportItems!textbox125.Value),"N0") > Format(cint(ReportItems!textbox126.Value),"N0") , "Green",IIF( Format(cint(ReportItems!textbox125.Value),"N0") = Format(cint(ReportItems!textbox126.Value),"N0") , "Orange","Orange")))however some number are still showing the wrong colour !eg textbox125=9 shows as green when textbox126 = 13 !and textbox125=10 shows as red when textbox126 = 7 !do you know what would cause this ? |
|
|
jamie
Aged Yak Warrior
542 Posts |
Posted - 2009-11-17 : 04:04:48
|
hicould this be an error with the formatting ?ie, it is looking at the 1 in 10 and the 9 in 9,is it possible to put a 0 infront of numbers before 10 ? |
|
|
JCirocco
Constraint Violating Yak Guru
392 Posts |
Posted - 2009-11-17 : 06:29:41
|
First, remove the format operative and see if it works or gives you an idea.Then instead of using the format operative, use the Format property for the text box.JohnIt's a small world (but I wouldn't want to paint it) |
|
|
|
|
|
|
|