Results 1 to 8 of 8
  1. #1
    Join Date
    Apr 2013
    Posts
    4

    Unanswered: Random password generation - How To?

    Good morning all.

    I am fairly new to Access and have a large customer database which i want to auto generate a random password in the 'Password' column (8 Charachters)
    I need the script to loop through all the records generateing the required data.

    I ahve found this script on this forum:
    Function CreatePassword(nLen As Long) As String
    Dim nRnd As Double
    Dim sPW As String
    Dim bAdd As Boolean

    Randomize
    While Len(sPW) < nLen
    nRnd = Int(Rnd * 75) + 48
    bAdd = False
    Select Case nRnd
    Case 48 To 57 ' Numeric characters
    bAdd = True
    Case 65 To 90 ' Upper case characters
    bAdd = True
    'Case 97 To 122 ' Lower case characters
    ' bAdd = True
    Case Else ' Useless characters
    bAdd = False
    End Select

    If bAdd Then
    sPW = sPW & Chr(nRnd)
    If (Len(sPW) = nLen - 1) And (Asc(Left$(sPW, 1)) < 65) Then
    sPW = Right$(sPW, Len(sPW) - 1)
    End If
    End If
    Wend

    CreatePassword = sPW
    End Function

    But I dont know exactly how to use it?

    Can someone please guide me through the process in Access 2010 on how I utalise this data?

    I also would like to autogenerate the login using the company name first few characters from that column to form part of lthe login credentials?

    Is this even possible?

    Thanks in advance.

    Your humble student

    Richard!

  2. #2
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    its a function
    the nlen defiens the number of character in the password
    so the call is
    Code:
    NewPassword = CreatePassword(8) 'assuming you want an 8 character password
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Apr 2013
    Posts
    4
    Great thanks for that.

    I dont want to sound stupid but where do I paste this script in Access 2010 so It will run?

    Thanks in advance.

  4. #4
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    insert the function into a vba code module, wheterthats a form or report or more likely just a code module is up to you
    depends where you want to use it

    if its declared public and in a code module then it can be used anywhere in your access application, even queries (assuming your are using the default data storage mechanism in Access)

    where do you expect it to run?
    I'd rather be riding on the Tiger 800 or the Norton

  5. #5
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    however a waord of warnig
    if the purpose of your password is to provide some form of security then storing the password in clear is meaningless as without careful design the passwords will be visioble to any user
    the usual approach is to store the password in encrypted form, often a hashcode of the password. which means you have a problem
    you need to find a way encrypting the password for storage,
    you need a method to tell your users what password to use that is reasonable secure,
    you need a method to encrypt the users's passwaord as entered to amtch it against the stored value
    you need a means of stopping malicious users seeing your encryption process (that probably means deploying the app as an MDE, and whilst you are at it as a split app with separate date (back end) and user interface (front end[s])
    I'd rather be riding on the Tiger 800 or the Norton

  6. #6
    Join Date
    Apr 2013
    Posts
    4
    Ok I have a table with lots of data there is a Password (8char text) field that needs populating using this method. Security here is not a concern as the users will only use the password once in the application they are relevant to and then they will change it. I am using the table for a mail merge and need the use once passwords autogenerating for me.

    I have created a module wit the VBA code pasted in (attached) but as I am a beginner user I have no Idea how to make it relevant to that 'Password' column of data in the table and execute it.
    (images attached)
    Attached Thumbnails Attached Thumbnails 2013-04-17 13_05_19-Microsoft Visual Basic for Applications - Ecolocker Installer Database - [Ge.jpg   2013-04-17 13_07_34-Microsoft Access - Ecolocker Installer Database _ Database (Access 2007 - 20.png  

  7. #7
    Join Date
    Nov 2004
    Location
    out on a limb
    Posts
    13,692
    Provided Answers: 59
    security is relevant and it shoudlbe a concern

    unless you take adequate steps to secure the data then you have a problem with the date being visible to others

    the other problem that remains is how you distribute the new password

    you should never store password in cleartext, anybody who can gain access to the table will have access to that account

    even if you encrypt the password someone who has an account and therefore a password \and who also has access to the table can (probably) work out what the encryption method you are using

    if the purpose of having a password is to provide some form of security then you have to design he application with that in mind.

    what you could do is encrypt the password, and add the plaintext in another column, as users logon for the first time, clear the plaintext
    distribute the plain text by email/sms/note/whatever
    . this also provides you with a mechanism to reset the password
    I'd rather be riding on the Tiger 800 or the Norton

  8. #8
    Join Date
    Apr 2013
    Posts
    4
    Hi there. This Access database is not linked to the application (website) where the user passwords will be stored / changed / relevant etc. This is just a mail merge database that I am going to use to send out the initial login passwords. therefore I cannot encript the passwords as they need to be printed on the letters.
    I am just using this repository for the mail out and need to generate the 1st login passwords so I dont have to make them all up (1000's of them)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •