Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

number field calc with a leading zero


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

Recommended Posts

Posted

I would like to have the setField function calc a numeric result with a leading zero. I have tried various ways but no luck.

TextToNum(Right("00"&Max(serial) + 1,2))

TextToNum(Right("00"&NumToText(Max(serial) + 1),2))

Posted

Let's say your current serial number is 1234, so the next one would be 1235. Apply your calculation to it Right( "001235", 2 ), and what do you get? 35.

You don't only want the two right-most digits; you want the entire number appended by at least one leading zero. Well, how large is your serial? Let's say it's 6 digits. Now, if you always want a leading zero, then you would need to use Right( "0000000" & serial + 1, 7 ). Otherwise, Right( "000000" & serial + 1, 6 ) will give you a leading zero for all serials up to 99999, which may be satisfactory, and will be consistent.

Posted

Sorry... the serial number is just a two digit number, but what I am having trouble with is setting the result to a number field. It will always drop the leading zero's.

Posted

Sorry rivet, your result will have to be text if you want to show the leading zeros. Unformatted raw numbers in FM will always have leading and training zeros dropped. You can show trailing zeros by formatting the field, but unfortunately leading zeros will still be dropped.

Since you are using this as a serial number you can still do whatever you need to, such as auto-enter serial number, etc. Change the calculation result to text and it will work.

This topic is 7525 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.