By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,854 Members | 833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,854 IT Pros & Developers. It's quick & easy.

How to create a random password and setup a change password form?

P: 51
Any ideas on how to send info from one form into another domain or how to write a default value for a new user's password with a formula?

Here's what I'm trying to do: design my database so that a new employee record has a password generated with a formula (obviously, not one that is published). On the employees table is a true false declaring if the user's password needs changed. The default value is true. So when I create a new record (add an employee to the table) he is given an unguessable (but not actually random) password and the tables marks his password as needing changed.

Now, on the login form, the command button checks if that user's password is marked as needing changed. If it is, it closes the login form and opens the change password form. What I need the command button on the change password form to do is change the value if the user's password (from the auto-calculated one) to the one he entered in the change password form AND to change the true/false value on that user's require change password box to false. Make sense?

So

1. How do I make the default password = to a formula (like the date the employee was added and their initials, etc) and

2. How do I code the command button on the change password form do the saving if the info change like I described earlier? Any tips?
Jan 23 '11 #1
Share this Question
Share on Google+
7 Replies


P: 8
Jesse,

I understand exactly what you're trying to do, and I know how to do it, but unfortunately I don't know the code for it. You want to concatenate your fields. Concatenate means to "add" your fields together. So basically it'll look like this:

"date" + "initials"

that will show up as 010811ml

something like that. Now as I've said, I don't know the code for it, but that's the concept that you need.

Sorry I couldn't be of more help.
Jan 26 '11 #2

P: 51
Thanks, Marty. How would you do it? The only reason I think I don't actually need code to originate the password.

Also, do you know the code that changes the value of a field in another table? (On my employee table, there is a yes/no that decides if the employee needs to be forced to change their password. If it says yes, they are redirected to a password change form. What I need is for the command button on that password change form to 1. set the password in employees = the password they just entered on the change form and 2. change the value of that yes/no to no.) Anyone have any suggestion?
Jan 29 '11 #3

100+
P: 374
I am unsure if this is the answer you are looking for but it is what I do for my database and it runs a lot smoother than trying to generate random/unique passwords.

Whenever I add a new person to my database the default password is set to "Password".

In my login form I check the entered password (as you do). If this password is = to Password I redirect the person t the "change password" form. I use a simple message box to display "Since this is the first time you have entered the databse, using the default password you are now required to change this." or similar.

It saves a lot of headaches generating new passwords etc when realisticly it is easier to let people all use 1 password to login for the first time and then ensure they change this to something else.
Jan 29 '11 #4

P: 51
Okay, munkee, thanks. I used to do it that way, but we had a problem with people overwriting other people's passwords. Not everyone has the same permissions in the database. So when I hire someone into database development with near total access, I don't want people in communications to be able to change the new guys password. Make sense?

Thank you for your thought. You could be a huge help to me though by perhaps sharing with me what you have done with you password change form. I assume its a modal form with a command button...? What is the coding on that button that changes the users password? I mean, how do you automatically save their new password?

Any help would be greatly appreciated. I am basically a novice in this.
Jan 29 '11 #5

100+
P: 374
I'll post some code in the morning
Jan 29 '11 #6

Rabbit
Expert Mod 10K+
P: 12,374
As far as security goes, you may want to take a look at this thread. http://bytes.com/topic/access/insigh...atabase-access

For a default password, I assume you have an add employee form. I would put a button on there that sets the password.

As for the password change, when they click the log in, I would use a dloopup to check if they need to change their password. If they do, I would open up a modal form for them to change their password. When they click a change password button, it would run an update SQL.
Jan 29 '11 #7

100+
P: 374
Here are the two sets of code I use.

The first is to validate a user login and to check if they have their password set to "Password" to redirect them to the change password form.

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOk_Click()
  2. On Error GoTo Err_cmdOk_Click
  3. '-----------------------------------------------------------------------------------------------------------------------------
  4. ' This code is used to validate users found in the tblSecurity table. If the wrong user name or password is
  5. ' provided access is denied.
  6. '-----------------------------------------------------------------------------------------------------------------------------
  7.     Dim db As DAO.Database
  8.     Dim rst As DAO.Recordset
  9.     Dim rstV As Recordset
  10.     Dim stDocName As String
  11.     Dim stLinkCriteria As String
  12.  
  13.     Set db = CurrentDb()
  14.     Set rst = db.OpenRecordset("tblSecurity", dbOpenDynaset)
  15.  
  16.     If Not IsNull(Me.txtUser) And Not IsNull(Me.txtPassword) Then
  17.         rst.FindFirst "Password = '" & Me.txtPassword & "'" & " And UserID = '" & Me.txtUser & "'"
  18.  
  19.         If rst.NoMatch Then
  20.             MsgBox "You entered the wrong User Name or Password." & Chr(13) & _
  21.             "Please enter the correct User Name and Password or " & Chr(13) & _
  22.             "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
  23.         ElseIf Me.txtPassword = "password" Then
  24.             MsgBox "This is the first time using the database or your passowrd has been reset." & Chr(13) & _
  25.             "You must change your password before you can enter the database.", _
  26.             vbOKOnly + vbExclamation, "Change Password"
  27.             stDocName = "frmUserLogonNew"
  28.             stLinkCriteria = "[UserID]=" & "'" & Me![txtUser] & "'"
  29.             DoCmd.OpenForm stDocName, , , stLinkCriteria
  30.         Else
  31.             stDocName = "frmSplashScreen"
  32.             DoCmd.OpenForm stDocName, , , stLinkCriteria
  33.             Me.Visible = False
  34.         End If
  35.     Else
  36.         MsgBox "You left the User Name and/or Password blank." & Chr(13) & _
  37.         "Please enter the correct User Name and Password or " & Chr(13) & _
  38.         "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Logon Denied"
  39.     End If
  40.  
  41.  
  42.     With Forms!frmhidden
  43.         .txtViewID = rst.Fields("ViewID")
  44.         .txtAccessID = rst.Fields("AccessID")
  45.         .txtActive = rst.Fields("Active")
  46.         .txtPassword = rst.Fields("Password")
  47.         .txtUserID = rst.Fields("UserID")
  48.         .txtSecurityID = rst.Fields("SecurityID")
  49.         .txtFName = rst.Fields("FName")
  50.         .txtSName = rst.Fields("SName")
  51.         .txtEMailAd = rst.Fields("EmailAd")
  52.         .txtUDept = rst.Fields("UDept")
  53.     End With
  54.  
  55.  
  56.  
  57.  
  58. Exit_cmdOk_Click:
  59. rst.Close
  60. Set rst = Nothing
  61. Set db = Nothing
  62.     Exit Sub
  63.  
  64. Err_cmdOk_Click:
  65.     Me.Visible = True
  66.     MsgBox Err.Description
  67.     Resume Exit_cmdOk_Click
  68.  
  69. End Sub

The second part of the code is my change password form allowing users to supply a new password twice and update their info:

Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdOk_Click()
  2. On Error GoTo Err_cmdOk_Click
  3. '-----------------------------------------------------------------------------------------------------------
  4. ' This code is used to change the user password in the 'tblSecurity table.
  5.  
  6.     Dim stDocName As String
  7.     Dim stLinkCriteria As String
  8.  
  9.     If Not IsNull(Me.txtNPassword) And Not IsNull(Me.txtCPassword) Then
  10.         If Me.txtCPassword = Me.txtNPassword Then
  11.             stDocName = "qryUpdateUserPassowrd"
  12.             DoCmd.SetWarnings False
  13.             DoCmd.OpenQuery stDocName, acNormal, acEdit
  14.             DoCmd.SetWarnings True
  15.             MsgBox "Password was successfully change", vbOKOnly + vbInformation, "Password Changed"
  16.             stDocName = "frmSplashScreen"
  17.             DoCmd.OpenForm stDocName, , , stLinkCriteria
  18.         Else
  19.             MsgBox "New password and confirmation do not match." & _
  20.             Chr(13) & "Please enter the correct password and confirm", vbOKOnly + vbInformation, "Incorrect Password"
  21.         End If
  22.     Else
  23.         MsgBox "You left the User Name and/or Password blank." & Chr(13) & _
  24.         "Please enter the correct User Name and Password or " & Chr(13) & _
  25.         "contact the Database Adminstrator for assistance.", vbOKOnly + vbCritical, "Change Failed"
  26.     End If
  27.  
  28. Exit_cmdOk_Click:
  29.     Exit Sub
  30.  
  31. Err_cmdOk_Click:
  32.     MsgBox Err.Description
  33.     Resume Exit_cmdOk_Click
  34.  
  35. End Sub
The query the above references to has the following sql:

Expand|Select|Wrap|Line Numbers
  1. UPDATE tblSecurity SET tblSecurity.[Password] = Forms!frmUserLogonNew!txtCPassword
  2. WHERE (((tblSecurity.UserID)=[Forms]![frmUserLogonNew]![txtUser]));
  3.  
Jan 31 '11 #8

Post your reply

Sign in to post your reply or Sign up for a free account.