Formatting a Phone Number Field This program note can be used to change a 10-digit telephone number into a format with parenthesis around the area code and a dash after the prefix into a standard format of: (408) 252-5700 Make sure your telephone number is a text field, then at the Program Spec, type the following: Phone Number: #1: #1 = "(" + @LEFT(@NUM(#1),3) + " ) " + @MID(@NUM(#1),4,3) + "-" + @RIGHT(@NUM(#1),4) Note: This programming statement can also be used as a Mass Update Spec to correct the format of telephone numbers that have been imported from an ASCII file. An alternate program statement will reformat any type of phone number input into a different standard form of: 408-252-5700 If a number is entered without an area code, this will add the local area code. If a number is entered that is not recognized, it will not be changed. Enter these statements on the Program Spec: Phone Number: >#1: IF @LEN (@NUM(#1)) = 7 THEN #1 = "408-" + @LEFT (@NUM(#1),3) + "-" + @RIGHT(@NUM(#1),4) ELSE IF @LEN (@NUM(#1)) = 10 THEN #1 = @LEFT (@NUM(#1),3) + "-" + @MID (@NUM(#1),4,3) + "-" + @RIGHT (@NUM(#1),4) Replace the 408, above, with your local area code. The above statement can be entered in a single field using the available long value memory. It could be modified to accept more formats (i.e. extensions, etc.) but it would require more room. Application: An order entry application could benefit by having all of the phone numbers in the same format, even though they were entered by many different people. ****4.0 NOTE**** You can also format a field by using the Field Template feature. This feature is located under File/Design/Customize. A phone number field would appear as follows: Phone#: (###) ###-#### If you wanted a specific area code this could be entered as well. Phone#: (408) ###-#### If you are entering data and want to override the Template, this can be done by pressing Alt-F4. Q & A Application Note Rev. 6/92 #2117 Page 1 of 1