From andrew.olenick@prudential.com:
Use this code in the Exiting telephone field event. The user types in i.e. 2153339865 and the code formats the number.
Sub Exiting(Source As Field) On Error Goto err_SOLPhoneExit Dim workspace As New NotesUIWorkspace Set doc = workspace.CurrentDocument SOLPhone = doc.FieldGetText("telephone") ' If SOLPhone is null or like (123) 456-7890 then exit If SOLPhone = "" Or SOLPhone Like "([0-9][0-9][0-9]) [0-9][0-9][0-9]-[0-9][0-9][0-9][0-9]" Then Exit Sub ' If SOLPhone is 10 positions and numeric, insert dashes and enter into SOLPhone field Elseif Len(SOLPhone) = 10 And Isnumeric(SOLPhone) Then tSOLPhone = "(" + Left(SOLPhone,3) + ") " + Left(Right(SOLPhone,7),3) + "-" + Right(SOLPhone,4) Call doc.FieldSetText("telephone",tSOLPhone) Exit Sub Else ' if SOLPhone in error, give message Dim answer As Integer tSOLPhone = SOLPhone answer = Messagebox ("Enter the area code, exchange, and extension without the punctuation. The Phone # will be automatically formatted in (123) 456-7890 format. Please try again.", MB_OK, "SOLPhone Incorrect") Call doc.FieldSetText("telephone",tSOLPhone) Call doc.GOTOFIELD("telephone") Exit Sub End If err_SOLPhoneExit: Messagebox "Error " & Err() & ": " & Error() Exit Sub End Sub