Clayhead22
Registered User.
- Local time
- Today, 21:35
- Joined
- Feb 22, 2015
- Messages
- 36
Hi. I have built a login form that works fine currently with the exception of login attempts. The current features are
1) Checks login is in users table.
2) Ensures the user status is not blocked in the table.
3) Sends the user to the correct page based on their authorisation in the user table.
What i need to do now is
1) Allow the user to enter the incorrect password 3 times and on the 4th time it will say "Too many login attempts. Your user access has been blocked."
2) Update their status as blocked in the users table.
My Current code is below. Please can someone help fix this?
I have tried 6 different codes to try and add this and i cant get any of them to work. Please help me fix it?
1) Checks login is in users table.
2) Ensures the user status is not blocked in the table.
3) Sends the user to the correct page based on their authorisation in the user table.
What i need to do now is
1) Allow the user to enter the incorrect password 3 times and on the 4th time it will say "Too many login attempts. Your user access has been blocked."
2) Update their status as blocked in the users table.
My Current code is below. Please can someone help fix this?
Code:
Private Sub LoginButton_Click()
Dim Useraccess As String
Dim Userstatus As String
If IsNull(Me.LoginUsernameText) Then
MsgBox "Please Enter Username", vbInformation, "Username Required"
Me.LoginUsernameText.SetFocus
ElseIf IsNull(Me.LoginPasswordText) Then
MsgBox "Please Enter Password", vbInformation, "Password Required"
Me.LoginPasswordText.SetFocus
Else
Userstatus = DLookup("Status", "Users", "Username = '" & LoginUsernameText & "'")
If Userstatus = "Blocked" Then
MsgBox "User access has been blocked. Please contact your system administrator."
Else
If (IsNull(DLookup("[Username]", "Users", "[Username] ='" & Me.LoginUsernameText.Value & "' And password = '" & Me.LoginPasswordText.Value & "'"))) Then
MsgBox "Incorrect Username or Password"
Else
MsgBox "Password accepted! Welcome to XRAIC CRM"
Useraccess = DLookup("Authorisation", "Users", "Username = '" & LoginUsernameText & "'")
If Useraccess = "Admin" Then
DoCmd.OpenForm "Interface"
Else
If Useraccess = "User" Then
DoCmd.OpenForm "InterfaceL1"
End If
End If
End If
End If
End If
End Sub