Generate set of Passwords in Access

Anonymous
2011-06-21T06:23:05+00:00

I ha ve an access database that contains the following columns :

UserID |First name  | Last Name | Username

I would like to add a password column as well and generate random passwords for the number of records found in my database , example if I have 50 records then I need to generate 50 password , 1 for every record

Any idea ?

Microsoft 365 and Office | Access | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
Anonymous
2011-06-23T16:58:46+00:00

What are the better ways ?

 

As suggested upthread, include both a Password field and a date/time field PasswordExpires. When you create a new user give them a password that's really easy - "password" for example! - and set the PasswordExpires field to =Date().

Then in your logon process check the expiration date. If it's less than or equal to Date() make them assign a new password of their own choice. You can enforce "strong" passwords by (say) ensuring that their entry is of mixed case or contains at least one number:

Dim blnPwdOk As Boolean

If StrComp([txtPassword], LCase([txtPassword]), 0) = 0 Then

  MsgBox "Password must contain at least one uppercase letter", vbOKOnly

  blnPwdOk = False

Elseif StrComp([txtPassword], UCase([txtPassword]), 0) = 0 Then

  MsgBox "Password must contain at least one lowercase letter", vbOKOnly

  BlnPwdOk = False

< use Instr to check for digits and/or special characters >

You may also want to set the PasswordExpires field to some date (say three months in the future) after you update the password.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

15 additional answers

Sort by: Newest
  1. ScottGem 68,855 Reputation points Volunteer Moderator
    2012-06-25T12:52:16+00:00

    Hi, I followed your instructions but everytime I run the query I get the following message: unidentified function 'fgenPassword' in expression.  Can you help?

     

    Obviously you didn't follow instructions exactly. But the question remains why are you trying to do this since it makes no sense.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2012-06-25T02:22:21+00:00

    Hi, I followed your instructions but everytime I run the query I get the following message: unidentified function 'fgenPassword' in expression.  Can you help?

     

    There was a message from John Spencer earlier (over a year earlier!!!) in this thread containing the code for fgenPassword. If you had (as John suggested) copied and pasted this code into a new module and compiled it your code should work, though I fully agree that your users will HATE you when you succeed, and will work their best to defeat your intent. If that's ok with you here's the code again:

    Public Function fGenPassword(iLen As Integer, vAnyField as Variant)

    'vAnyField is required to force the function to be called for each row in the query

    Dim iLoop As Integer

    Dim iRandom As Integer

    Dim strReturn As String

       Randomize

       For iLoop = 1 To iLen

          strReturn = strReturn & Chr(Int((125 - 33 + 1) * Rnd + 33))

       Next iLoop

       fGenPassword = strReturn

    End Function

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2012-06-22T14:19:35+00:00

    Hi, I followed your instructions but everytime I run the query I get the following message: unidentified function 'fgenPassword' in expression.  Can you help?

    Was this answer helpful?

    0 comments No comments
  4. ScottGem 68,855 Reputation points Volunteer Moderator
    2011-06-23T18:53:33+00:00

    What are the better ways ?

     

    Instead of asking us questions how about answering ours? If you explain what you are trying to accomplish we can be specific about a better way.

    John offered you one instance and I had offered you another. Each solution involves using a default password for all and having the user enter a personal password when they enter the default. In my case, I use a PWReset field to indicate when the user needs to enter their own passport in John's passwords automatically expire after time.

    But you do not want to use a Randomly generated password.

    Was this answer helpful?

    0 comments No comments