Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×
The Claris Museum: The Vault of FileMaker Antiquities at Claris Engage 2025! ×

This topic is 5393 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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

Posted (edited)

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 by Guest
Providing two options for calculations
Posted

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

)

)

Posted

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 ###.

Posted

I believe this a bit faster:


Let(

theValue = Filter (Self; "1234567890");



Case(Length(theValue) = 10;



Replace(Replace ( theValue ; 3 ; 0 ; " " );8;0;" ");





Self

)

)

--sd

  • 2 weeks later...

This topic is 5393 days old. Please don't post here. Open a new topic instead.

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.