Jump to content
Sign in to follow this  
K1200

How to increment a text field?

Recommended Posts

I have what would be classified as a "text serial number" that I need to increment by 1 upon certain user actions. The field needs to display with leading zeroes. For example: "0001002" would increment to "0001003". Can this be done without using a custom "pad text" function?

Share this post


Link to post
Share on other sites

Hi

any text field with autoenter option can do what you are after; simply start with "next value" = 0001001

Share this post


Link to post
Share on other sites

K1200:

The trick is to make it a Text field, not a Number field. This will keep the leading zeros in place.

-Stanley

Share this post


Link to post
Share on other sites

Thanks for the response.

These fields are not actual serial numbers, so I can't use the normal auto-increment method that FileMaker provides in the field definition. The numbers need to be incremented after the record is created (in response to user actions), so what I'm needing is a "text math" method that can accommodate the leading zeros.

Stanley: the field is already text. How can it be incremented?

Share this post


Link to post
Share on other sites

See if this works:

right("0000000" & getasnumber(field) + 1; 7)

Share this post


Link to post
Share on other sites

Amazingly (to me), it DOES work! -- but I can't exactly see how it does. It seems it would simply concatenate the "000000" on the front of the incremented result, but somehow it merges. I know I'm overlooking something in trying to understand this, but what?

UPDATE:

OK, I see it. It does merge, but then eliminates the "overflow". (This has just been one of THOSE days.)

Thanks.

Share this post


Link to post
Share on other sites

The perfect choice.

An aside: my search of the Calculation Forum this morning for "increment" didn't show any result that I could recognize as a solution. Now (after the fact)searching FileMaker's Help turns up nine topics; SerialIncrement is number six. Note to self: "must remember to try multiple resources when stumped". Consolation: "maybe someone will see these posts and learn from them".

Thanks, comment.

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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