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

    Generate password value following specific rules

    Access 2003 .mdb (but some users may have 2007 or 2010 so it needs to work in all versions)


    I want to generate a password based on specific rules. The password would generate either off a button push or more likely on the “after update” of an earlier field (probably username).
    Needs to be 7 characters
    Only 1 Capital Letter
    2 lower case letters
    3 numbers
    1 special character
    Needs to be unique
    Any help with this would be appreciated


    tia
    Dave
    Last edited by ducecoop; 10-27-2010 at 11:58 AM.

  2. #2
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    you rules can use to check if the password is valid. but need more rules to general a (initial) password.
    do you mean that you want random letter or numbers? do you have a list of "special characters"?

  3. #3
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41
    Quote Originally Posted by weekend00 View Post
    you rules can use to check if the password is valid. but need more rules to general a (initial) password.
    do you mean that you want random letter or numbers? do you have a list of "special characters"?
    Yes - Random Numbers and letters (Within the constraints above)
    Special characters are what ever would be legal in Access and/or Exchange. Limiting to these would be fine (!@#$%&*_?+)

    Thanks
    Dave

  4. #4
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    modify the field names and table name to fit in your database in
    DLookup("password", "yourtable", "password='" & RndPass & "'") = Null

    then call UniquePass() to get unique passowrd.

    Code:
    Public Function UniquePass() As String
        Do
        Loop While DLookup("password", "yourtable", "password='" & RndPass & "'") >""
    End Function
     
    Public Function RndPass() As String
    '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)
        RndPass = passwd
    End Function

  5. #5
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41
    weekend00
    wow!
    works great - thanks
    One other thing I wanted (but did not say) is to randomize the order (Not always cap first, not always Spec Char last).

    It is NOT critical as I think this will still provide "hard to crack" passwords
    but if it is easy (meaning not worth a lot of additional trouble)- it would be nice.

    Thanks again

    Dave

  6. #6
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    Code:
    Public Function UniquePass() As String
        Dim passwd As String
        Dim passwd2 As String
        Dim i As Integer
        Do
            passwd = RndPass
        Loop While DLookup("password", "yourtable", "password='" & passwd & "'") > ""
    'disorder password
        passwd2 = ""
        Do While passwd <> ""
            i = Int(Len(passwd) * Rnd) + 1
            passwd2 = passwd2 + Mid(passwd, i, 1)
            passwd = Mid(passwd, 1, i - 1) + Mid(passwd, i + 1)
        Loop
        UniquePass = passwd2
    End Function

  7. #7
    ducecoop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    41
    Thank you very much.
    You have made me a hero

    Dave

  8. #8
    weekend00 is offline I may not be right
    Windows XP Access 2003
    Join Date
    Aug 2010
    Posts
    1,295
    u r welcome.

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

Similar Threads

  1. Replies: 2
    Last Post: 10-23-2010, 09:38 AM
  2. Validation Rules
    By esglover in forum Database Design
    Replies: 1
    Last Post: 07-23-2010, 08:02 PM
  3. Validation rules question
    By cps6568 in forum Access
    Replies: 3
    Last Post: 01-12-2010, 02:01 PM
  4. Generate Image
    By dbman in forum Import/Export Data
    Replies: 0
    Last Post: 01-31-2008, 10:46 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