Here's a quickie function I just threw together. I haven't tested it
thouroughly, but it seems to work.
'----- start of code -----
Function RandomString(LengthNeeded As Integer) As String
Static blnRandomized As Boolean
Dim strOut As String
Dim I As Integer
Dim intChar As Integer
Const conSourceChars As String = _
"abcdefghijklmnopqrstuvwxyz" & _
"ABCDEFGHIJKLMNOPQRSTUVWXYZ" & _
"0123456789"
If Not blnRandomized Then
Randomize
blnRandomized = True
End If
For I = 1 To LengthNeeded
strOut = strOut & _
Mid(conSourceChars, _
1 + Int((Rnd() * Len(conSourceChars))), _
1)
Next I
RandomString = strOut
End Function
'----- end of code -----
You'd call it like this:
strNewPassword = RandomString(6)
Notice that I've assumed that all characters must be drawn from the set
of letters or digits. You can add to that list by modifying the
constant conSourceChars.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)