Option Explicit
Option Compare Database
Public lngMyEmpID As Long
Option Explicit
Option Compare Database
Private intLogonAttempts As Integer
Private Sub Form_Open(Cancel As Integer)
Me.cboEmployee.SetFocus
intLogonAttempts = 0
End Sub
Private Sub cboEmployee_AfterUpdate()
Me.txtPassword.SetFocus
End Sub
Private Sub cmdLogin_Click()
If IsNull(Me.cboEmployee) Or Me.cboEmployee = "" Then
MsgBox "User Name is a required field.", vbOKOnly, "Required Data"
Me.cboEmployee.SetFocus
Exit Sub
End If
If IsNull(Me.txtPassword) Or Me.txtPassword = "" Then
MsgBox "Password is a required field.", vbOKOnly, "Required Data"
Me.txtPassword.SetFocus
Exit Sub
End If
If Me.txtPassword.Value = DLookup("strEmpPassword", "tblEmployees", "[lngEmpID]=" & Me.cboEmployee.Value) Then
lngMyEmpID = Me.cboEmployee.Value
DoCmd.Close acForm, "frmLogon", acSaveNo
DoCmd.OpenForm "frmSplash_Screen"
Else
MsgBox "Password Invalid. Please Try Again", vbOKOnly, "Invalid Entry!"
Me.txtPassword.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts = 3 Then
MsgBox "You do not have access to this database. Please contact your system administrator.", vbCritical, "Access to Access is Restricted!"
Application.Quit
End If
End Sub
Option Explicit
Option Compare Database
Private Sub Form_Close()
DoCmd.SelectObject acTable, "tblEmployees", True
End Sub
Private Sub Form_Timer()
DoCmd.Close
End Sub
|