April 15, 200421 yr 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))
April 15, 200421 yr 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.
April 16, 200421 yr Author 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.
April 16, 200421 yr 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.
Create an account or sign in to comment