IEW Posted May 27, 2004 Posted May 27, 2004 I have found the function "If ( CODE="1" ; TextColor(NAME;RGB(150;0;0))". I have a field "name" and a field "code". If "code"=1 I want to turn the "name" field text red. I cant get this to work any ideas? TIA Ivan
dbruggmann Posted May 27, 2004 Posted May 27, 2004 You can't change the colour of the text field self this way, only the content of the calculation field which uses the TextColor function.
MoonShadow Posted May 27, 2004 Posted May 27, 2004 Actually, I believe you can. With FM7 you can use that as an auto-enter calculation on your Name field. Be sure to unclick right under 'by calculation' the box that says "Do not replace existing value." In this way, the text color will continually change depending upon the Code.
dbruggmann Posted May 27, 2004 Posted May 27, 2004 Cool! It works (but I had to reenter the values, after applying the auto enter calculation to the text field).
IEW Posted May 27, 2004 Author Posted May 27, 2004 code=1 changecolor field "If (CODE=1 ; TextColor ( NAME ; RGB (250; 0 ; 0 ) ) ; TextColor (NAME ; RGB ( 0 ; 0 ; 0 ) ) )" Only thing that changes is the contents of "word field" "name" in changecolor field. If only I could make "name field" = "changecolor field"
IEW Posted May 27, 2004 Author Posted May 27, 2004 create script to: Set name field = changecolor field. Need a "SetField" command in the calculation collection, this would be a snap. Ivan
MoonShadow Posted May 28, 2004 Posted May 28, 2004 Why are you using another field called changecolor? This calculation attached to your Name field will allow the name to change to reddish when Code = 1. TextColor(Name; (Code = 1) * 9830400 ). This is the most efficient way to code it. Just be sure to unclick right under 'by calculation' the box that says "Do not replace existing value." That's the key. This next one will only display the name in red if Code = 1 otherwise the field will remain empty. If(Code; TextColor (Name; RGB ( 150; 0; 0) )). I had to throw this in ... I really like it with auto-enter! It is nicer than requiring validation on a field. Instead of insisting a field remain empty, it quietly and sweetly removes the data instead. This auto-enter ability (in FM7) replaces many script steps and validation requirements, such as formatting for phone numbers, etc. This particular calc (not allowing data in a field) makes me smile and I have come up with all kinds of uses for it. I have Manager's box for 'Manager Comments Only'. If Privilege Set isn't Manager, the User's entry doesn't stick. Detlev said... but I had to reenter the values, after applying the auto enter calculation to the text field. Unclick 'Do Not Evaluate...' in the calculation dialog. But you are correct, I believe, in that you'd need to force a recalculation if you wish to change the color of the text in a standard field (pre auto-enter calculation). You could loop with one script step: Set Field [Code, Code]. It doesn't matter what field it sets but Code (being numeric 1) might be quicker. Even Replace Contents (same calc). Simply setting any field to itself will force an update according to the record's auto-enter calculation.
Recommended Posts
This topic is 7820 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now