May 15, 200817 yr 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
May 15, 200817 yr 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.
May 15, 200817 yr Author 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
May 15, 200817 yr 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.
May 15, 200817 yr 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 "?".
Create an account or sign in to comment