This all should be handled via layout-level conditional format and actual text should remain unformatted in any way. What version of FM are you using? :^)
Try the following Auto-enter calculation:
Substitute ( TextFormatRemove ( Self ) ; Customer_Name ; TextColor ( Customer_Name ; RGB ( 255 ; 0 ; 0 ) ) )
This will remove all formatting except for the customer's name, which will be changed to red text. The red colour won't take effect until the user commits the record by clicking out of the field.
Note that it's also case sensitive, so if the name isn't spelled exactly as it appears in the Customer_Name field, the red colour won't appear.
FMP 11 Advanced...
Thanks. How would you add another Field to the same string: Such as First_Name...?
TextFormatRemove ( Self ) ;
[ first_name ; TextColor ( first_name ; RGB ( 255 ; 0 ; 0 ) ) ] ;
[ last_name ; TextColor ( last_name ; RGB ( 255 ; 0 ; 0 ) ) ]
Is there any way that the colour formatting part of this calculation can switched on or off? With the text format part being applied all the time.
Looks like I have solved my own problem.
A global field carrying a Y or N value. A script and button to change the value of the global filed.
Then the original calculation changed into the IF calculation....
Again. You are colorizing actual text throughout your table. And you cannot find records with colored text nor can you use global to remove it. The fact that you want to 'switch the color on and off' points to my point. You should handle the coloring of text from either straight calculation or from layout level (display) only.
Your global field will only affect the record you are currently viewing. If you leave other records colorized, and wish to print in black and white (for example), your text with red will print in off-black and look terrible. So you will want to find your record set and have to reset all the fields before printing. Simply, you will figure this out eventually and remove coloring your data. When that happens, revert to suggestion of using a calculation or using conditional formatting at the layout level.
I see what you mean. I will play with this one fior a while and see what I can come up with.