Hi, I have to find a way to create a unique account number for every user that signs up for a system that i was asked to create, but i need a little help!
If anyone is able to answer this question that will be a great step forward for me.
What i need is to be able to take the first 3 characters from their last name then add a 4 digit number to the end
example: MCG-1234
I have no control over how i get the name as it is supplied from another source and comes as one line like so - First Middle Last
example: Charles Stuart McGrotty
I want to first 3 letter of the last name only followed by a - (hyphen), then a random 4 digit number that is not already used with the 3 letter prefix
another example:
My account number may be MCG-2843
another account starting with MCG may be MCG-3846, it can NOT have MCG-2843 as that is already taken by me.
But if the last name was Smith then SMI-2843 is allowed.
I hope I have not lost you...
So, how do I trim the name to give me just the first 3 letters of the last name, and how do i make sure that the 4 digit number after this is uniqu to that 3 letter prefix, but still available for a different 3 letter prefix?
To add to the complexity, there may not be a middle name, so it could just be Allen Smith (no middle name).
So looking for the second (space) character in the string will not work as there may only be 1.