September 3, 200718 yr I have a layout with 3 radiobuttons for setting priorities. (Urgent, Normal, Low) I would like to change the color of the text in a different field based on the choice a user makes on the radio buttons. Sorry these questions are elementary scripting questions... What is the function that returns the value from a field? AND what is the function that can be used to change the color of a text in a field?
September 3, 200718 yr You don't need a script - only apply an Auto-Enter calculation to your [color:blue]text field (the one you wish to change colors). Insert this calculation in the Options, Auto-Enter, calculated value: Case ( [color:blue]radiobutton = "Urgent" ; TextColor ( [color:blue]text ; RGB ( 255 ; 0 ; 0 ) ) ; [color:blue]radiobutton = "Normal" ; TextColor ( [color:blue]text ; RGB ( 0 ; 255 ; 0 ) ) ; TextColor ( [color:blue]text ; RGB (0 ; 0 ; 255 ) ) ) Change [color:blue]radiobutton to the name of your radio button field. Change [color:blue]text to the name of your text field. Change your colors as needed. Be sure to uncheck (also on the Auto-Enter tab), the checkbox 'Do Not Replace Existing value.' Modify this calculation depending upon your needs. If you need help, let us know. :wink2: Edited September 3, 200718 yr by Guest Corrected calculation
September 3, 200718 yr Author Thank you very much. One more thing. Do I need to explicitly reference the radiobutton or the field if the change in color is expected in a different layout? Edited September 3, 200718 yr by Guest
September 3, 200718 yr No, when you reference a field within the field definition window, then it applies to that field everywhere (because you specify the context within the calculation dialog itself). UPDATE: Let me rephrase that a bit ... if you place that calculation on different layouts, it will work the same. But yes, you must reference the fields within it. And, if the layout is related to the table where the field exists, it will work. In other words ... I have no idea what you are getting at and I'm punting right now. :wink2: Edited September 3, 200718 yr by Guest
September 3, 200718 yr Isn't this about version 9? Why not use conditional formatting? Old habits die hard? Are there enough questions here?
September 3, 200718 yr I tried conditional formatting. But I could not get more than two options in it. I could not make it work, Michael - only work like boolean - format or not format. Please show how 3 different colors based upon 3 different criteria might look in one calculation ... I tried both value and formula. And no, not too many questions! ROFLMFAO! I've only played with conditional formatting a few times now making text disappear by changing it to background color, etc but nothing multi-criteria. Ha ha! Edited September 3, 200718 yr by Guest
September 3, 200718 yr They need to be in reversed order, compared to what you would do in a Case() function.
September 3, 200718 yr Formula is test::radiobutton ≠"Low" and test::radiobutton = "Urgent" ( format red text ) Formula is [color:red]test::radiobutton ≠ "Urgent" and test::radiobutton = "Normal" ( format green text ) There might be simpler ways but this works. UPDATE: First line removed - default unnecessary. Added: default color is whatever you wish - black or blue or ... ha ha REMOVE THE PART IN RED! Edited September 3, 200718 yr by Guest
September 3, 200718 yr Somehow I forgot this was based on a radio button - I was already thinking how to make this with ranges. With a radio button, it is indeed simpler, because only one condition can be true, so the order doesn't matter. Formula is test::radiobutton = "Urgent" ( format red text ) Formula is test::radiobutton = "Normal" ( format green text )
September 3, 200718 yr I kept whittling on it. I was certain I had tried that at first and it didn't work. But it does now. I realize it was because I was attempting to put a Case() statement within it.
September 3, 200718 yr Here's an example of a pseudo-Case conditional formatting. ConditionalFormatByRange.fp7.zip
Create an account or sign in to comment