Results 1 to 7 of 7
  1. #1
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41

    Password generation does not seem random

    Access 2003



    I am using the following code on the AfterUpdate event of a field event
    to generate a random password in another 2 fields.

    seems to often give the same password but then sometime change to something different and again stays the same for awhile.

    Code:
    Private Sub LastName_AfterUpdate()
    '1 Capital Letter
    '2 lower case letters
    '3 numbers
    '1 special character
    Dim passwd As String
    Const specialChar = "!@#$%&*_?+"
    
    '1 Capital Letter
    passwd = Chr(Int(26 * Rnd) + Asc("A"))
    '2 lower case letters
    passwd = passwd + Chr(Int(26 * Rnd) + Asc("a"))
    passwd = passwd + Chr(Int(26 * Rnd) + Asc("a"))
    '3 numbers
    passwd = passwd + Format(Int(1000 * Rnd), "000")
    '1 special character
    passwd = passwd + Mid(specialChar, Int(Len(specialChar) * Rnd) + 1, 1)
    
    
    Me.ComputerPassword.Value = passwd
    Me.ComputerUser = LCase(Left([FirstName], 1)) & "" & LCase(Replace(Replace(Replace([LastName], "-", ""), " ", ""), "ñ", "n"))
    
    Me.EmailPass.Value = passwd
    Me.EmailUser = LCase(Left([FirstName], 1)) & "" & LCase(Replace(Replace(Replace([LastName], "-", ""), " ", ""), "ñ", "n"))
    
    End Sub
    This is generated on a pop-up form

    Any ideas that how I can make this unique?

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I believe if you read up on the Rnd() function in Help you'll find it needs to be preceded by Randomize.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41
    Quote Originally Posted by pbaldy View Post
    I believe if you read up on the Rnd() function in Help you'll find it needs to be preceded by Randomize.
    rnd is in each line of code.
    Am I using it incorrectly?

    Thanks for the reply

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    Maybe this will help.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41
    pbaldy thanks for the reply

    That did not help, but reviewing some previous posts of mine did. I just needed to take my programing a step further.

    Thanks again

  6. #6
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    I'm curious what that step was.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  7. #7
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41
    Quote Originally Posted by pbaldy View Post
    I'm curious what that step was.
    I did not follow all the steps here

    https://www.accessforums.net/access/...ules-8910.html

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Automatic Report Generation - Access VBA
    By initiator in forum Programming
    Replies: 2
    Last Post: 04-19-2010, 05:10 AM
  2. Random Rdn() Funtion Help Please
    By graviz in forum Access
    Replies: 1
    Last Post: 12-09-2009, 11:57 AM
  3. Random numbers
    By Gator777 in forum Access
    Replies: 3
    Last Post: 08-12-2009, 10:04 AM
  4. Correspondence Reference Number Generation
    By ildanach in forum Forms
    Replies: 1
    Last Post: 04-28-2009, 12:09 PM
  5. Change from old password to new password
    By richy in forum Security
    Replies: 0
    Last Post: 11-17-2005, 05:05 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums