yafreax Posted March 30, 2001 Posted March 30, 2001 I know this has been talked about, sorry. I need five leading zero's then the serial number, Is this syntax (of the top of my head) the best / correct way to do it. (I'm trying to make you 're job easy, if yes, say yes, if no, correct me please.) Serial Field [ number field, starting with 1 increment by 1] Leading Zero Field [Calc as follows: case( length(Serial_field) =1, "00000" & Serial_field, length(Serial_field) = 2, "0000" & Serial_Field, length(Serial_Field) = 3, "000" & serial_field, length(Serial_Field) = 4, "00" & Serial_Field, length(Serial_Field) = 5, "0" & Serial_Field, Serial_Field) Looks okay to me, not going to be in FM for rest of day though so can't check it, please advise as to if this is a good way to do it and if not, how should i do it. . . Thanks buddies Jeremy

LiveOak Posted March 30, 2001 Posted March 30, 2001 If you setup the starting serial number in define fields as "00001", all the serial numbers will appear this way (00001,00002,etc.) if you leave the field formatting as "leave number as entered". -bd

yafreax Posted April 2, 2001 Author Posted April 2, 2001 boy, that's easy, thanks jeremy (I'm not as smart as i think i am, I try to lie but i tell the truth, i try and try it's just no use i am a foolish, foolish man. --Satellite Soul)

yafreax Posted April 2, 2001 Author Posted April 2, 2001 scratch much of my first post. I don't need the serial number ( it was a miscommunication problem ). What i have is basically 3 fields: Start_Number [ number = 000001] Qnty [Number, user enters] End_Number [calc; Start_Number = Qnty] So if a user selects 500 for the qnty, i need 000501 to show in the End_Number field, however, even with leaving formatting as entered, i get 501 in the End_Number field. The Start_Number is correct in showing the leading zeros, it's just after the calculation that they are eliminated, but i need them desperately. What to do, what to do. . . Jeremy

BobWeaver Posted April 2, 2001 Posted April 2, 2001 How 'bout: End_Number = Right("00000"&(Start_Number+qnty),5) Again make sure you set the number format for End_Number to "Leave data formatted as entered" [ April 02, 2001: Message edited by: BobWeaver ]

Gogargirl Posted April 3, 2001 Posted April 3, 2001 Create another calc field based on this calc: Case((start + qnty <10) and (start + qnty >0) , "00000" & end , (start + qnty <100) and (start + qnty >= 10) , "0000" & end , (start+ qnty <1000) and (start + qnty >= 100) , "000" & end , (start+ qnty <10000) and (start + qnty >=1000) , "00" & end, (start + qnty <100000) and (start + qnty >=10000) , "0" & end , (start + qnty >= 100000), end,"")Case((start + qnty <10) and (start + qnty >0) , "00000" & end , (start + qnty <100) and (start + qnty >= 10) , "0000" & end , (start+ qnty <1000) and (start + qnty >= 100) , "000" & end , (start+ qnty <10000) and (start + qnty >=1000) , "00" & end, (start + qnty <100000) and (start + qnty >=10000) , "0" & end , (start + qnty >= 100000), end,"")Case((start + qnty <10) and (start + qnty >0) , "00000" & end , (start + qnty <100) and (start + qnty >= 10) , "0000" & end , (start+ qnty <1000) and (start + qnty >= 100) , "000" & end , (start+ qnty <10000) and (start + qnty >=1000) , "00" & end, (start + qnty <100000) and (start + qnty >=10000) , "0" & end , (start + qnty >= 100000), end,"") 'Elegance' is not my middle name - but this does work. What surprises me is that I thought it would only work if the calculation was formatted for a text result, but it works as a number too....unless I'm missing something utterly obvious!

Gogargirl Posted April 3, 2001 Posted April 3, 2001 Whoa!! Somehow that calc pasted 3 times. Once is enough... Case((start + qnty <10) and (start + qnty >0) , "00000" & end , (start + qnty <100) and (start + qnty >= 10) , "0000" & end , (start+ qnty <1000) and (start + qnty >= 100) , "000" & end , (start+ qnty <10000) and (start + qnty >=1000) , "00" & end, (start + qnty <100000) and (start + qnty >=10000) , "0" & end , (start + qnty >= 100000), end,"")

## Recommended Posts

This topic is

8625 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