Advertisement
Guest User

VBA Code

a guest
May 14th, 2016
471
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Option Compare Database
  2.  
  3. Private Sub cboUser_AfterUpdate()
  4.     Me.txtPassword.SetFocus
  5. End Sub
  6.  
  7. Private Sub btnLogin_Click()
  8.  If IsNull(Me.cboUser) Or Me.cboUser = "" Then
  9.       MsgBox "You must enter a User Name.", vbOKOnly, "Required Data"
  10.         Me.cboUser.SetFocus
  11.         Exit Sub
  12.     End If
  13.  
  14.     If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
  15.       MsgBox "You must enter a Password.", vbOKOnly, "Required Data"
  16.         Me.txtPassword.SetFocus
  17.         Exit Sub
  18.     End If
  19.    
  20.     If Me.txtPassword.Value = DLookup("Password", "Users", _
  21.             "[Users]=" & Me.cboUser.Value) Then
  22.            
  23.        lngMyEmpID = Me.cboUser.Value
  24.        
  25.        Else
  26.       MsgBox "Password Invalid. Please Try Again", vbOKOnly, _
  27.             "Invalid Entry!"
  28.         Me.txtPassword.SetFocus
  29.     End If
  30.  
  31.     'If User Enters incorrect password 3 times database will shutdown
  32.  
  33.     intLogonAttempts = intLogonAttempts + 1
  34.     If intLogonAttempts > 3 Then
  35.       MsgBox "You do not have access to this database.Please contact admin.", _
  36.                vbCritical, "Restricted Access!"
  37.         Application.Quit
  38.     End If
  39.  
  40. End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement