December 1, 200421 yr Newbies 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.
December 2, 200421 yr 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))
December 2, 200421 yr 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 ) )
Create an account or sign in to comment