I created the routine that counts the number of attempts of the user to login to the system, if the password is lost five times the system blocks the user. But my code is not taking into account the user code (access login), that is, always putting different users in the five attempts, in the fifth attempt the system will block the user who was last tried. I put in the 'users' table the 'attempt' column, however it always counts + 1 even changing the user login. Can anyone help?
--variável
Private fiContador As Integer
--código
Private Sub cmdEntrar_Click()
If txtSenha.Text <> lTBUsuarios("senha") Then 'Rotina que conta as tentativas de login
lsql = ("SELECT tentativa FROM usuarios WHERE id_usuario = " & txtLogin.Text)
MsgBox lsql
fiContador = fiContador + 1
If lTBUsuarios("tentativa") >= 5 Then
MensagemErro "O usuário foi inativado."
txtLogin.SetFocus
lsql = "UPDATE USUARIOS SET status = '" & "INATIVO" & "', tentativa = '" & "0" & "' WHERE id_usuario = " & txtLogin.Text & ""
gBDSistemaIntegrado.Execute lsql
Else
'fazer 1, 2, 3, 4, e 5 if vendo quantos registros de tentativa tem para o usuário
'em cada um deles colocar o valor do fiContador = 1, 2, 3, 4, ou 5
lsql = "UPDATE USUARIOS SET tentativa = '" & fiContador & "' WHERE id_usuario = " & txtLogin.Text & ""
gBDSistemaIntegrado.Execute lsql
MensagemErro "Senha inválida. Tentativa " & fiContador & " de 5."
txtSenha.Text = ""
txtSenha.SetFocus
Exit Sub
End If
Exit Sub
End If