Guest User

Untitled

a guest
May 21st, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. Private Sub cmdAddPoints_Click()
  2.  
  3. Dim RSAddPoints As Recordset
  4. Dim MyAnswer As String
  5.  
  6. MyAnswer = MsgBox("Do you wish to add/remove " & Me.txtNoOfPoints & " points to the student ID " & Me.txtStudentID & "?" _
  7. , vbYesNo)
  8.  
  9. If MyAnswer = vbYes Then
  10.  
  11. Set RSAddPoints = CurrentDb.OpenRecordset("tblPoints", dbOpenDynaset)
  12.  
  13. RSAddPoints.AddNew
  14.  
  15. RSAddPoints!StudentID = Me.txtStudentID
  16. RSAddPoints!StaffID = Me.txtStaffID
  17. RSAddPoints!Reason = Me.cmbReason
  18. RSAddPoints!NumberOfPoints = Me.txtNoOfPoints
  19. RSAddPoints!DateOfPointChange = Me.txtDate
  20.  
  21. RSAddPoints.Update
  22. RSAddPoints.MoveLast
  23.  
  24. Dim RSStudent As Recordset
  25.  
  26. Set RSStudent = CurrentDb.OpenRecordset("tblStudent", dbOpenDynaset)
  27.  
  28. RSStudent.MoveFirst
  29.  
  30. Do While Not RSStudent.EOF
  31.  
  32. If Me.txtStudentID = RSStudent!StudentID Then
  33.  
  34. RSStudent!TotalPoints = RSStudent!TotalPoints + Me.txtNoOfPoints
  35.  
  36. RSStudent.Update
  37.  
  38. Exit Do
  39.  
  40.  
  41. Else
  42.  
  43. RSStudent.MoveNext
  44. End If
  45.  
  46. Loop
  47.  
  48.  
  49.  
  50. MsgBox (Me.txtNoOfPoints & " points were added to the Student ID " & Me.txtStudentID)
  51.  
  52.  
  53. Me.txtStudentID = ""
  54. Me.txtStaffID = ""
  55. Me.cmbReason = ""
  56. Me.txtNoOfPoints = ""
  57. Me.txtDate = ""
  58.  
  59. Else
  60. End If
  61. End Sub
Add Comment
Please, Sign In to add comment