April 6, 201015 yr Hi! I'm using Windows 7 and Filemaker Pro 10 Advanced. I'm having a field "Phone 1". This field is for local Mobile Numbers (10 digits) As someone enters a number XXXXXXXXXX, I want it to reformat automatically to XX XXXX XXXX. What kind of calculation do I need to do... I'm brand new to calculations... Thanks for all the help I can get! /Fred
April 6, 201015 yr The calculation you are looking for may be something like this: Case( Length(Self) = 10; Middle(Self; 1; 2) & " " & Middle(Self; 3; 4) & " " & Middle(Self; 7; 4); Self ) or even this if you want to handle a wider variety of input values consisting of 10 digits with arbitrary spacing: Let( theValue = Substitute(Self; " "; ""); Case( Length(theValue) = 10; Middle(theValue; 1; 2) & " " & Middle(theValue; 3; 4) & " " & Middle(theValue; 7; 4); Self ) ) Use this in the Auto-Enter Calculated value part of the field's definition. Uncheck the box for Do not replace existing value of field. Edited April 6, 201015 yr by Guest Providing two options for calculations
April 6, 201015 yr I would also recommend using the filter function. Let( theValue = filter (self; "1234567890"); Case( Length(theValue) = 10; Middle(theValue; 1; 2) & " " & Middle(theValue; 3; 4) & " " & Middle(theValue; 7; 4); Self ) )
April 6, 201015 yr Hmmm, you say you are using FM Pro Advanced but your profile shows FM Pro so I'll assume you have access to creating custom functions. I would suggest using this custom function by The Shadow here. It covers all User possibilities and provides a visual format of what it should contain. If you want the format to display #### instead of underscore, check further up in the thread for another example by The Shadow where he formats with ###.
April 6, 201015 yr I believe this a bit faster: Let( theValue = Filter (Self; "1234567890"); Case(Length(theValue) = 10; Replace(Replace ( theValue ; 3 ; 0 ; " " );8;0;" "); Self ) ) --sd
Create an account or sign in to comment