Create Random Password

R

RickyRed

I am trying to move my Network Administrator over from Approach to Access.
He has some formulas in Approach that do the following when he creates a new
network account:
1. Creates a random, unique 3-letter 3-number password (in uppercase) such
as ABC123.
2. Creates a unique username by using the first character of the first name
and up to 7 characters of the last name (for a total of 8 characters max).
Appending a numeral to the end if a username already exisits...such as
JSmith3.
3. Creates a random, unique 6-digit PIN code for copier use, such as 674839.

I have some experience with coding, string functions, etc. Need some help
with the random creation part, and I'm not sure how to tackle the part that
checks to see if the random value created already exists. Many thanks for
any help/direction,

-Rick
 
K

Klatuu

Use the Rnd function to create a random number that is six characters long
formatted as a string:

Randomize
strNewPin = Format(Int((999999 * Rnd) + 1), "000000")

It see if it already exists, use the DLookup to see if it exists in the table:

If Not IsNull(DLookup("[PIN]", "tblSecurity", "[PIN] = '" & strNewPin & "'")
Then
MsgBox "This PIN Already Exists"
End If
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top