3 Replies Latest reply on Sep 23, 2010 11:57 AM by philmodjunk

    text color



      text color


      In layout mode: how can I create a script that changes the color of text in one field based on the value of a second field?

      I see how to add "If" and "end if" to a script and I found the text function called "TextColor(field name;rgb(255,0,0))" but I can't figure out how to get that function into the script.

        • 1. Re: text color

          While what you want could be done, it is simpler to use conditional formatting for this.

          On the field whose color you want to change, use a conditional format expression like this:

          Table::secondField = 1 //specify the value you need instead of 1

          and select the color for the conditional format.

          • 2. Re: text color

            That worked fine except I had one surprise.  I went to table view and in the layout did the conditional formating. When I went back to table view all the appropriate records were red as expected.  However the conditional formating didn't carry over to another layout whcih I am using for data entry. So I had to add the same condiional format in the edit layout mode for that second layout.  Then it worked there as well.  I had hoped that the conditional formating for the fields in the table would carry over to all occurances of that data in all other layouts and reports which I plan to develope.  In other words, I had hoped that the condional formating for that particular field would be "global".

            I can live with this but I had hoped .....

            Thanks for your prompt help.

            • 3. Re: text color

              The more complex alternative is to define a calculation field such as

              If ( Field1 = 1 ; TextColor(field2 ;rgb(255,0,0)) ; field2 )

              and place this field on all your layouts instead of Field2.

              If this field must be editable, you may be able to use an auto-enter calculation provided both fields are defined in the same table:

              If ( Field1 = 1 ; TextColor( self ; rgb(255,0,0)) ; self )