Leather Knight Posted January 3, 2006 Posted January 3, 2006 How do I fet a filter to work for phone numbers? IE: 555-555-1212 would convert to (555) 555-1212? I see Let(phone = filter(theField;"0123456789");"(" & left(phone;3) & ")" & middle(phone;4;3) & "-" & middle(phone;7;4)) But do not know how to get it to work. Thanks
mr_vodka Posted January 3, 2006 Posted January 3, 2006 The easiest way to use this formula is to create a custom_function out of it. Then on one of your fields that you want the formatting to occur, have it set to a calculated result with 'Do not replace...' unchecked. The calc forumla that you use would just be the custom_function applied to the field. There are also numerous other posts in regards to phone number formatting on these forums.
Leather Knight Posted January 4, 2006 Author Posted January 4, 2006 I defined the phone field to use the custom function, but then I get "this field is not modifiable" ;)
Ender Posted January 4, 2006 Posted January 4, 2006 Don't use a regular calculation. Use a text field with an Auto-Entered Calculation (with the "Do not replace.." option unchecked.)
Leather Knight Posted January 4, 2006 Author Posted January 4, 2006 Ok I must be missing something. I did it and the function does not convert. The function I am using is: Let ( input = Filter (Phone ; "0123456789" ) ; Case ( input ; Case ( Length ( input ) = 7 ; Replace ( input ; 4 ; 0 ; "-" ) ; Length ( input ) = 10 ; Replace ( Replace ( Replace ( input ; 7 ; 0 ; "-" ) ; 4 ; 0 ; ") " ) ; 1 ; 0 ; "(" ) ; Length (input ) = 11 and Left ( input ; 1 ) = "1" ; Replace ( Replace ( Replace ( Right ( input ; 10 ) ; 7 ; 0 ; "-" ) ; 4 ; 0 ; ") " ) ; 1 ; 0 ; "(" ) ; input & TextColor ( " too few or too many digits" ; 16711680 ) ) ) )
mr_vodka Posted January 4, 2006 Posted January 4, 2006 Here is a sample file using a modified version of your sample code. Phone_sample.zip
Recommended Posts
This topic is 6962 days old. Please don't post here. Open a new topic instead.
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