Guest User

Untitled

a guest
Dec 1st, 2017
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. Option Compare Database
  2. Private intLogonAttempts As Integer
  3.  
  4.  
  5. Private Sub cmdLogin_Click()
  6. If IsNull(Me.cboUsername) Or Me.cboUsername = "" Then
  7. MsgBox "You must enter a User Group.", vbOKOnly, "Required Username"
  8. Me.cboUsername.SetFocus
  9. Exit Sub
  10. End If
  11.  
  12. If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  13. MsgBox "You must enter a Password.", vbOKOnly, "Enter Password"
  14. Me.txtPassword.SetFocus
  15. Exit Sub
  16. End If
  17.  
  18. 'login if statements
  19. If Me.txtPassword.Value = DLookup("Password", "tblSTAFF", "[ID]=" & Me.cboUsername.Value) Then
  20.  
  21. ID = Me.cboUsername.Value
  22.  
  23. DoCmd.Close acForm, "frmStaffLogin", acSaveNo
  24.  
  25. If ID = 1 Then
  26. DoCmd.OpenForm "frmSubTeach"
  27.  
  28. ElseIf ID = 2 Then
  29. DoCmd.OpenForm "frmFormTeach"
  30.  
  31. ElseIf ID = 3 Then
  32. DoCmd.OpenForm "frmHeadOfYear"
  33.  
  34. End If
  35.  
  36. Else
  37. MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Incorrect Password."
  38. Me.txtPassword.SetFocus
  39. End If
  40.  
  41. 'attempts counter
  42. intLogonAttempts = intLogonAttempts + 1
  43. If intLogonAttempts > 3 Then
  44. MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Restricted Access!"
  45. End If
  46.  
  47. End Sub
Add Comment
Please, Sign In to add comment