Code:
Public Sub Login()
On Error GoTo ErrorHandler:
If IsNull([cboUser]) = True Then 'Check UserName
MsgBox "Użytkownik jest wymagany"
ElseIf IsNull([txtPassword]) = True Then 'Check Password
MsgBox "Hasło jest wymagane"
Else
'Compare value of txtPassword with the saved Password in tblUser
If Me.txtPassword.Value = DLookup("Password", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") Then
strUser = Me.cboUser.Value 'Set the value of strUser declared as Global Variable
strRole = DLookup("Role", "tblUsers", "[UserName]='" & Me.cboUser.Value & "'") 'set the value of strRole declared as Global Variable
DoCmd.Close acForm, "frmLogin", acSaveNo
'MsgBox "Witam ponownie, " & strUser, vbOKOnly, "Welcome"
DoCmd.OpenForm "Menu", acNormal, "", "", , acNormal
Else
MsgBox "Hasło nie poprawne.Spróbuj ponownie.", vbOKOnly, "Złe Hasło"
intLogAttempt = intLogAttempt + 1
txtPassword.SetFocus
End If
End If
'Check if the user has 3 wrong log-in attempts and close the application
If intLogAttempt = 3 Then
MsgBox "Nie masz dostępu skontaktuj się z Administratorem" & vbCrLf & vbCrLf & _
"Aplikacja wyłączy się.", vbCritical, "Zabroniony dostęp!"
Application.Quit
End If
ErrorHandler:
MsgBox Err.Number & ", " & Err.Description & " in sub Login of form frmLogin"
End Sub
Your existing error handler does nothing but ignore errors without any notification. Suggest you add the above red code line.