Jump to content

Leading Zeros (once again)


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

Recommended Posts

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

Link to comment
Share on other sites

scratch much of my first post. I don't need the serial number ( it was a miscommunication problem wink.gif" border="0 ).

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

Link to comment
Share on other sites

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!

Link to comment
Share on other sites

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,"")

Link to comment
Share on other sites

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