Saubs Posted April 11, 2008 Posted April 11, 2008 My solution has invoice numbers with five digits followed by a letter. I'd like to let my users preview what the subsequent invoice number in a particular series would be, before it's created (why? Long Story). In other words, if invoices 20000a, 20000b, and 20000c exist, then I want a tooltip to show that the next invoice to be created in the 20000 series would be 20000d. Auto-enter serial numbers are not being used, btw. I'm working on a formula that's getting me close: Let ( [ trailingLetter = Right ( invoiceNumber ; 1 ) ; trailingLetterAsNumber = Position ( "abcdefghijklmnopqrstuvwxyz" ; trailingLetter ; 1 ; 1 ) ; trailingLetterPlusOne = trailingLetterAsNumber + 1 ; subsequentLetter = GetAsText ( trailingLetterPlusOne ) ] ; Left ( invoiceNumber ; 5 ) & subsequentLetter & " is the next invoice in this series." ) I need to get the next-to-last line of this formula to convert the number to a letter. Obviously, GetAsText isn't going to work, and I don't know what will. Hope this makes sense; Suggestions greatly appreciated. Many thanks--
comment Posted April 11, 2008 Posted April 11, 2008 (edited) How about: Let ( [ alpha = "abcdefghijklmnopqrstuvwxyz" ; trailingLetter = Right ( invoiceNumber ; 1 ) ; trailingLetterAsNumber = Position ( alpha ; trailingLetter ; 1 ; 1 ) ; subsequentLetter = Middle ( alpha ; Mod ( trailingLetterAsNumber ; 26 ) + 1 ; 1 ) ] ; Left ( invoiceNumber ; 5 ) & subsequentLetter & " is the next invoice in this series." ) Edited April 12, 2008 by Guest Another typo
BobWeaver Posted April 11, 2008 Posted April 11, 2008 Try this: Let ( [ trailingLetter = Right ( invoiceNumber ; 1 ) ; trailingLetterAsNumber = Position ( "abcdefghijklmnopqrstuvwxyz" ; trailingLetter ; 1 ; 1 ) ; trailingLetterPlusOne = trailingLetterAsNumber + 1 ; subsequentLetter = Middle ("abcdefghijklmnopqrstuvwxyza"; trailingLetterPlusOne );1 ] ; Left ( invoiceNumber ; 5 ) & subsequentLetter & " is the next invoice in this series." ) You still need to look after the situation where the current number ends in "Z", but this should get you going.
Saubs Posted April 12, 2008 Author Posted April 12, 2008 Thank you so much for your quick replies and useful suggestions, Comment and BobWeaver. Problem solved! Much appreciated.
Recommended Posts
This topic is 6128 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 accountSign in
Already have an account? Sign in here.
Sign In Now