Random password generation

  • Thread starter Thread starter Robin Chapple
  • Start date Start date
R

Robin Chapple

I have a membership database with 1000 records. Each has an email
address and I have extracted the 'username' part of the email address
to be the username for entry to a password protected database.

The password field is empty and I need to allocate a random six
character, alpha/numeric, code to each.

How do I do that?

Thanks,

Robin Chapple
 
Use the built-in Rnd function to generate pseudo-random numbers. You can use
them either as an index to an array of characters you want to use (eg.
Array(1) = A, Array(2) = B, and so on), or you can use them with the
built-in Asc function to generate characters.
 
Hi,

Function RandomPasswort(Optional ByVal IPwd_lng As Byte = 10) As String

Dim Obergrenze As Integer
Dim Untergrenze As Integer
Dim Wert1 As Integer

'Passwort > 5 and <= 12 characters -- else 10 charachter
If IPwd_lng < 5 Or IPwd_lng > 12 Then IPwd_lng = 10

Dim I As Integer
Dim Strx As String
Strx = ""

' Verwenden Sie die folgende Formel, um ganzzahlige Zufallszahlen innerhalb
eines bestimmten
' Bereichs zu erzeugen:
' Wert1 = Int((Obergrenze - Untergrenze + 1) * Rnd + Untergrenze)
' Obergrenze steht hier für die größte Zahl des Bereichs und Untergrenze für die
kleinste Zahl des Bereichs.

Obergrenze = 127 ' Ascii-Wert 127
Untergrenze = 33 ' Ascii-Wert 33

'Es werden alle Zeichen zwischen Dec. 33 und 127 wahlfrei erzeugt
Randomize

For I = 1 To IPwd_lng
Wert1 = Int((Obergrenze - Untergrenze + 1) * Rnd + Untergrenze)
Strx = Strx & Chr(Wert1)
Next I

RandomPasswort = Strx

End Function
 
My apologies Doug I must have asked on the wrong list. Much too
advanced for me.

Robin
 
Who cares whether the comments in the code are in German? Just copy
everything between the lines "Function RandomPasswort(Optional ByVal
IPwd_lng As Byte = 10) As String" and "End Function" (including those
lines) into a new module in your database.

To use Klaus's function to generate a 6 character password, do something
like:

Dim strPassword

Dim strPassword = RandomPasswort(6)
 
Hi,

thank´s a lot Doug.

i didn´t think that the german comments could be a problem ...
(otherwise i´d have deleted them)
 
Back
Top