password generating

xcao

Registered User.
Local time
Today, 04:53
Joined
Nov 25, 2003
Messages
40
I have a form with a button called generating password.
Every time there is a new client registration, we will
click the button and generate a password for the user.
But for some reason the passwords have a lot of
duplicates. I use random function, I guess there
shouldn't be duplicates, but actually not.
Any ideas about how can I avoid new password is the same
as existing passwords?
The following is the code when click the generating
password button:

Thanks in advance for any ideas
--------------
pwLength = 8

For i = 1 To pwLength
Randomize (0)
ChooseType = Round(Rnd)

If ChooseType = 1 Then
'Number'
Randomize (0)
pwStore = Chr(Int((57 - 48 + 1) * Rnd + 48))
Else
'Alphabet'
'only need Lower Case'
Randomize (0)
pwStore = Chr(Int((122 - 97 + 1) * Rnd + 97))
'End If
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 & "')"
-----------


Thanks

.
 
Try:
Randomize (Timer)
doevents

to reset the "seed"
and cause a slight delay
 
Did this solve the problem?
 

Users who are viewing this thread

Back
Top Bottom