A
Ann
I have a module that generates password. At first I
generate password for 50 users at one time, there is no
duplicated password, but then later if there is a new
user comes in, we need to generate a password
individually, but I found every time I do this, it
duplicates with another user's password in the table,
don't know why.
Here is the code:
--------------------
pwLength = 8
For i = 1 To pwLength
ChooseType = Round(Rnd)
If ChooseType = 1 Then
'Number'
pwStore = Chr(Int((57 - 48 + 1) * Rnd + 48))
Else
'Alphabet'
'Lower Case'
pwStore = Chr(Int((122 - 97 + 1) * Rnd + 97))
End If
pw = pw & pwStore
Next i
MsgBox "Password generated = " & pw
'append to tblLobUsers table username and password
username = Me.ComLobReg
DoCmd.RunSQL "Insert into UserPass (Username, Password)
Values(" & username & ", '" & pw & "')"
generate password for 50 users at one time, there is no
duplicated password, but then later if there is a new
user comes in, we need to generate a password
individually, but I found every time I do this, it
duplicates with another user's password in the table,
don't know why.
Here is the code:
--------------------
pwLength = 8
For i = 1 To pwLength
ChooseType = Round(Rnd)
If ChooseType = 1 Then
'Number'
pwStore = Chr(Int((57 - 48 + 1) * Rnd + 48))
Else
'Alphabet'
'Lower Case'
pwStore = Chr(Int((122 - 97 + 1) * Rnd + 97))
End If
pw = pw & pwStore
Next i
MsgBox "Password generated = " & pw
'append to tblLobUsers table username and password
username = Me.ComLobReg
DoCmd.RunSQL "Insert into UserPass (Username, Password)
Values(" & username & ", '" & pw & "')"