This is the Code: (Please anyone, correct this)
Option Compare Database
Option Explicit
Dim intCount As Integer
Private Sub cmdCancel_Click()
DoCmd.Quit
End Sub
Private Sub cmdOK_Click()
On Error GoTo ValidUserError
If IsNull([txtUserPassword]) Or Len([txtUserPassword]) < 8 Or Len(txtUserName) < 8 Then
MsgBox "Invalid User Name or Password", vbCritical, "Logon Error"
[txtUserName].SetFocus
Exit Sub
Else
'Validate the user name and password
If DCount("UserName", "qryCurrentUser") = 1 Then 'limit the number of concurrent sessions allowed for each user
'txtUserID = DLookup("UserID", "qryCurrentUser")
' txtDept = DLookup("EmployeeDept", "qryCurrentUser")
'Use only if we need to validate the admin user
'If DLookup("[Admin?]", "qryCurrentUser") Then
DoCmd.OpenForm "Navigation Form"
Forms!frmLogon.Visible = False
'Else
'Dim stFilter As String
'stFilter = "DeptID = " & DLookup("EmployeeDept", "qryCurrentUser")
'DoCmd.OpenForm "Switchboard", , , stFilter
'Forms!frmLogon.Visible = False
'End If
Else
MsgBox "Error Validating User.", vbCritical, "Logon Error"
End If
End If
ValidUserExit:
Exit Sub
ValidUserError:
MsgBox Err.Description
Resume ValidUserExit
End Sub
Private Sub txtUserName_AfterUpdate()
If IsNull([txtUserName]) Then
MsgBox "Please enter User Name", vbCritical, "Logon User Name"
[txtUserName].SetFocus
End If
End Sub
Private Sub txtUserPassword_AfterUpdate()
If IsNull([txtUserPassword]) Or Len([txtUserPassword]) < 8 Then
MsgBox "Invalid Password", vbCritical, "Logon User Name"
[txtUserPassword].SetFocus
End If
End Sub