Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Option Compare Database
- Option Explicit
- *************************************************
- Dim rsUser As Recordset
- *************************************************
- Private Sub CMDUpdatePassword_Click()
- 'updates password
- If Len(Me.password.Value & "") = 0 Then
- MsgBox ("Please enter a valid password")
- Else
- UpdateUserPassword
- MsgBox "Your Password has been updated"
- End If
- End Sub
- *************************************************
- Private Sub CMDUpdate_Click()
- 'updates user details
- UpdateUser
- MsgBox "Your details have been updated"
- End Sub
- *************************************************
- Private Sub cmdExit_Click()
- DoCmd.Close 'Closes form
- End Sub
- *************************************************
- Private Sub Form_load() 'When the form loads do this -
- Me.tempID = gettempID()
- Set rsUser = CurrentDb.OpenRecordset("tblUser", dbOpenDynaset) 'Links the form to the table
- If rsUser.RecordCount = 0 Then 'If there are no records display this message
- MsgBox "Sorry there are no records to view", vbOKOnly, "No User found"
- Exit Sub
- Else
- rsUser.FindFirst ("Staff_ID = " & Me.tempID)
- ShowUser
- 'Me.tempName = tempName
- End If
- End Sub
- *************************************************
- Private Sub ShowUser()
- 'Gets the data from the relevent fields
- 'from the table and sticks them in the correct text boxes
- Me.tempID = rsUser!Staff_ID
- Me.username = rsUser!U_Username
- Me.firstname = rsUser!U_Firstname
- Me.surname = rsUser!U_Surname
- Me.title = rsUser!U_Title
- Me.emailaddress = rsUser!U_Emailaddress
- End Sub
- *************************************************
- Private Sub UpdateUser() 'Updates the data already in the table
- rsUser.Edit
- rsUser!U_Firstname = Me.firstname
- rsUser!U_Surname = Me.surname
- rsUser!U_Title = Me.title
- rsUser!U_Emailaddress = Me.emailaddress
- rsUser.Update
- End Sub
- *************************************************
- Private Sub UpdateUserPassword()
- rsUser.Edit
- 'saves password and encrypts it
- rsUser!U_Password = Encrypt(Me.password, 3)
- rsUser.Update
- End Sub
Add Comment
Please, Sign In to add comment