Guest User

Untitled

a guest
Apr 16th, 2016
27
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2. Option Explicit
  3. *************************************************
  4. Dim rsUser As Recordset
  5. *************************************************
  6. Private Sub CMDUpdatePassword_Click()
  7. 'updates password
  8. If Len(Me.password.Value & "") = 0 Then
  9. MsgBox ("Please enter a valid password")
  10. Else
  11. UpdateUserPassword
  12. MsgBox "Your Password has been updated"
  13. End If
  14. End Sub
  15. *************************************************
  16. Private Sub CMDUpdate_Click()
  17. 'updates user details
  18. UpdateUser
  19. MsgBox "Your details have been updated"
  20. End Sub
  21. *************************************************
  22. Private Sub cmdExit_Click()
  23. DoCmd.Close 'Closes form
  24. End Sub
  25. *************************************************
  26. Private Sub Form_load() 'When the form loads do this -
  27.  
  28. Me.tempID = gettempID()
  29. Set rsUser = CurrentDb.OpenRecordset("tblUser", dbOpenDynaset) 'Links the form to the table
  30.  
  31. If rsUser.RecordCount = 0 Then 'If there are no records display this message
  32.    MsgBox "Sorry there are no records to view", vbOKOnly, "No User found"
  33.     Exit Sub
  34.    
  35.     Else
  36.     rsUser.FindFirst ("Staff_ID = " & Me.tempID)
  37.     ShowUser
  38.     'Me.tempName = tempName
  39.    End If
  40.  
  41. End Sub
  42. *************************************************
  43. Private Sub ShowUser()
  44. 'Gets the data from the relevent fields
  45. 'from the table and sticks them in the correct text boxes
  46. Me.tempID = rsUser!Staff_ID
  47. Me.username = rsUser!U_Username
  48. Me.firstname = rsUser!U_Firstname
  49. Me.surname = rsUser!U_Surname
  50. Me.title = rsUser!U_Title
  51. Me.emailaddress = rsUser!U_Emailaddress
  52. End Sub
  53. *************************************************
  54. Private Sub UpdateUser() 'Updates the data already in the table
  55. rsUser.Edit
  56. rsUser!U_Firstname = Me.firstname
  57. rsUser!U_Surname = Me.surname
  58. rsUser!U_Title = Me.title
  59. rsUser!U_Emailaddress = Me.emailaddress
  60. rsUser.Update
  61. End Sub
  62. *************************************************
  63. Private Sub UpdateUserPassword()
  64. rsUser.Edit
  65. 'saves password and encrypts it
  66. rsUser!U_Password = Encrypt(Me.password, 3)
  67. rsUser.Update
  68. End Sub
Add Comment
Please, Sign In to add comment