JoL wrote:
Quote:
Access calls it a "mask" but in Filemaker8, is it possible to format
a field to make phone numbers appear with parenthesis and hyphen in
place like (123) 456-7890? |
This calculation comes from the custom functions library at
BrianDunning.com. You can use it as an Auto-Enter calculation for your
phone number field. In the second line, change YourFieldName to match
the actual field name being re-calculated.
It re-formats into a 333-333-4444 arrangement, assuming any additional
characters are an extension.
If there are too few characters, it formats the text in red.
This one does not insert parentheses, but a with a little fiddling, you
can see how to do that on your own, if you find that construct
absolutely necessary.
Matt
The calculation:
//Strip non-Numerics
Let( [TempNum= Filter( YourFieldName ; "0123456789");
//Remove leading 1
Num = If( Left(TempNum;1) = 1; Middle(TempNum;2;99);TempNum);
Phone =
// Test for empty Number
If( Length (Num) < 1; "" ;
//Otherwise...
Left (Num ; 3) & "-" & Middle(Num;4;3) & "-"& Middle(Num;7;4) &
// if longer than 7 characters assume it is an extension
If(Length(Num)> 10; " x" & Middle(Num;11;99);""))];
// if shorter than 7 characters display it in red as error
If(Length ( Num ) < 10;
TextColor ( phone ; RGB ( 255 ; 0 ; 0 ) );
// remove color format
TextColor ( phone ; RGB (0 ; 0 ; 0 ))))