Advertisement
Guest User

Untitled

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