Newbies Lisa S Posted December 1, 2004 Newbies Posted December 1, 2004 I am having trouble formatting a phone number field to display the phone number as (000)000-0000, I would also like an error message to display if an incorrect number of digits are entered. Wasn't sure to do it as calculation or number field, etc cannot find options nor sure of the code to format it this way. Any help would be greatly appreciated!! it is currently defined as a number field.
RalphL Posted December 2, 2004 Posted December 2, 2004 The phone number should be a text field. It is not a number, i.e., 5*Phone Number + 3 does not have any meaning. In pre FMP7 a calculated text field was placed on top of the entry field. The calculated field would then show the formatted phone number. you might try a calculation like this: Phone = Subsitute (Subsitute (Subsitute (Subsitute( "-", "")), "(", ""), ")", ""), "(", "") Case ( Lenght (Phone) <> 10, "Enter 10 digit phone number", "(" & Left ( Phone, 3) & ") " & Middle (Phone, 4, 3) & "-" & Middle (Phone, 7, 4))
-Queue- Posted December 2, 2004 Posted December 2, 2004 You could also use a trigger field of Left( GetField("Phone Number"), 0 ) & serial, and a self-relationship from trigger to serial, then make the Phone Number a lookup to the calculation field, based on the self-relationship. This would overwrite the entered number with the formatted one without requiring field stacking to create the mask. A little tweak to Ralph's calc, adding the substitution for a space and fixing a couple of typos: Case( Length(Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" )) <> 10, "Enter 10 digit phone number", "(" & Left( Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" ), 3 ) & ") " & Middle( Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" ), 4, 3 ) & "-" & Middle( Substitute( Substitute( Substitute( Substitute( Substitute( phone, "-", "" ), " ", "" ), "(", "" ), ")", "" ), "(", "" ), 7, 4 ) )
Recommended Posts
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