117Alan Posted May 15, 2008 Posted May 15, 2008 Hi I have a field containing a set of numbers (eg telephone number). Let’s say I want the field to contain eleven digits. If the incorrect amount of digits is entered I would like all the digits in the field to change colour say from black to red to alert the data entry person that there are too few or too many digits. While I realise I could use field validation to ensure that the correct number of digits are entered I would like to learn a calculation to satisfy the colour option. Can any one help with the calculation (or script) please? Thanks
mr_vodka Posted May 15, 2008 Posted May 15, 2008 You can use a field with an Auto-enter calculated value. Case ( Length ( PhoneNum ) ≠ 11; TextColor ( PhoneNum ; RGB (255 ; 0 ; 0 ) ); Evaluate ( PhoneNum ) ) Make sure that you have 'Do not replace existing value' Unchecked.
Fitch Posted May 15, 2008 Posted May 15, 2008 FYI this is even simpler in FM9 with conditional formatting.
117Alan Posted May 15, 2008 Author Posted May 15, 2008 Before I posed the question I did try with my own calculations which were unsuccessful. I tried with “If” and then with “case” but I never though of the last bit of your calculation “Evaluate” Could you explain please what the “Evaluate” bit does? thanks
mr_vodka Posted May 15, 2008 Posted May 15, 2008 Well since you are applying a text style change to the current value in the field, it will keep that style change unless you remove it. So if you have typed in something that isnt 11 characters, it will apply the style of text color red. If you left it like such: Case ( Length ( PhoneNum ) ≠ 11; TextColor ( PhoneNum ; RGB (255 ; 0 ; 0 ) ); PhoneNum ) Then although it is 11 characters, it will still be red since the field already has that style applied. The Evaluate in this instance basically allows you to return only the true data in it. You could also have used TextFormatRemove or TextColorRemove.
comment Posted May 15, 2008 Posted May 15, 2008 You cannot use Evaluate() alone just to remove the styling. You must protect the entry from being actually evaluated as an expression, by using the Quote() function: Evaluate ( Quote ( PhoneNum ) ) Otherwise, an entry of "123-456-7890" will return "-8223" (subtract 456 from 123, and 7890 from the result) and "(123) 456-7890" will return "?".
Recommended Posts
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