kolpdc
asked on
set fields (background-)color according to value of other field
hello experts,
i'm using crystal-reports embedded into visual studio 2003.
i have some linked tables. the datatable A holds a state-id belonging to another small table B that has concrete informations on how to show the value (text, color, backgroundcolor, ...).
now i have the text-field B_1 of B on my report showing the user-readable value. according to the state-id A_1 of table A i'd like to set the textcolor and backgroundcolor of B_1 which is shown to the user. i'm lost on how to colorize that field. does anyone of you have a concrete solution?
my problem is, that i do not have experience using cr's formula language. i thought of using a switch and strcmp on A_1. then according to the result set the color and backgroundcolor of B_1 to certain values.
Switch (
StrCmp ({A.A_1}, "offr"), colorizeMyField,
StrCmp ({A.A_1}, "inf"), colorizeMyFieldOtherWay,
StrCmp ({A.A_1}, "inf"), colorizeMyFieldOtherWay
)
do i have the right direction? can anyone of change my code the way it sets the forecolor and the backcolor of field {B.B_1} according to {A.A_1}?
thank you in advance
i'm using crystal-reports embedded into visual studio 2003.
i have some linked tables. the datatable A holds a state-id belonging to another small table B that has concrete informations on how to show the value (text, color, backgroundcolor, ...).
now i have the text-field B_1 of B on my report showing the user-readable value. according to the state-id A_1 of table A i'd like to set the textcolor and backgroundcolor of B_1 which is shown to the user. i'm lost on how to colorize that field. does anyone of you have a concrete solution?
my problem is, that i do not have experience using cr's formula language. i thought of using a switch and strcmp on A_1. then according to the result set the color and backgroundcolor of B_1 to certain values.
Switch (
StrCmp ({A.A_1}, "offr"), colorizeMyField,
StrCmp ({A.A_1}, "inf"), colorizeMyFieldOtherWay,
StrCmp ({A.A_1}, "inf"), colorizeMyFieldOtherWay
)
do i have the right direction? can anyone of change my code the way it sets the forecolor and the backcolor of field {B.B_1} according to {A.A_1}?
thank you in advance
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thank you. i'll check it. by the way - i've seen the following statement in my studios formula designer
Switch (expr1, function1, expr2, function2, ...)
Switch (expr1, function1, expr2, function2, ...)
I double-checked and you're right, the switch statement is in there. Apparently it's been added at some version and I never noticed it appeared. Obviously the syntax is different then what you had but certainly you could still use switch instead of the select..case or if..then.
frodoman
frodoman
ASKER
thank you frodoman - it just works fine.
wish you a nice time for rest of night, day, evening (take the one fitting your needs ;)...
wish you a nice time for rest of night, day, evening (take the one fitting your needs ;)...
Glad I could help - frodoman
The color set can be either a Crystal constant (crRed, crWhite, etc.) or you can customize it with the RGB function which takes the form "RGB(0-255 Red, 0-255 Green, 0-255 Blue)" -- I've shown examples of both above. If you use the crDefault then it'll be set to whatever color you've picked from the color-picker on the Format -> Border tab after putting a checkmark in the 'Background' field.
If you want to use the Select..Case structure it goes like this:
select {A.A_1}
case 'offr' : crRed
case 'inf' : RGB(100, 100, 100)
default: crDefault
HTH
frodoman