I have been searching for a VBA module to generate Unique random alphanumeric strings of random length (or length between X and Y number of characters)
I found the following one:
Source: https://stackoverflow.com/questions...al-basic-generate-random-string-in-text-field
The only issue I have with this function is that it automatically changes random string every time I click on the generated random string in the query Datasheet View. I would like the strings to be static not dynamic. Any way to modify the above module so that once the random strings are generate they cannot change?
Alternatively is there any other VBA module that allows me to generate Unique random alphanumeric strings of random length ?
Thank you
I found the following one:
Public Function GenerateUniqueSequence(numberOfCharacters As Integer) As String
Dim random As String ' * 8 'fixed length string with 8 characters
Dim j As Integer
Dim ch As Integer ' each character
random = ""
For j = 1 To numberOfCharacters
random = random & GenerateRandomAlphaNumericCharacter
Next
GenerateUniqueSequence = random
End Function
Public Function GenerateRandomAlphaNumericCharacter() As String
'Numbers : 48 is '0', 57 is '9'
'LETTERS : 65 is 'A', 90 is 'Z'
'letters : 97 is 'a', 122 is 'z'
GenerateRandomAlphaNumericCharacter = ""
Dim i As Integer
Randomize
i = (Rnd() * 2) + 1 'One chance out of 3 to choose one of 3 catégories
Randomize
Select Case i
Case 1 'Numbers
GenerateRandomAlphaNumericCharacter = Chr(Rnd() * 9 + 48)
Case 2 'LETTERS
GenerateRandomAlphaNumericCharacter = Chr(Rnd() * 25 + 65)
Case 3 'letters
GenerateRandomAlphaNumericCharacter = Chr(Rnd() * 25 + 97)
End Select
End Function
Source: https://stackoverflow.com/questions...al-basic-generate-random-string-in-text-field
The only issue I have with this function is that it automatically changes random string every time I click on the generated random string in the query Datasheet View. I would like the strings to be static not dynamic. Any way to modify the above module so that once the random strings are generate they cannot change?
Alternatively is there any other VBA module that allows me to generate Unique random alphanumeric strings of random length ?
Thank you