Hi,
I am struct with following code for my login form i have mentioned each code requirement but its not working.
Many thanks for your help.
I am struct with following code for my login form i have mentioned each code requirement but its not working.
Code:
Private Sub BtnLoginOK_Click()
Dim vpwd As Variant
On Error GoTo ErrorHandler:
'Check if username is entered.
If IsNull(txtUsername) Or Me.txtUsername = "" Then
MsgBox "Username is required", vbOKOnly, "Invalid Entry!"
txtUsername.SetFocus
Exit Sub
'Check if Password is entered.
If IsNull(txtPassword) Or Me.txtPassword = "" Then
MsgBox "Password is required", vbOKOnly, "Invalid Entry!"
txtPassword.SetFocus
End If
Exit Sub
'Check case sensivity of entered username and password is correct 'z123VF&@'.
If DCount("LoginID", "tblUserSecurity", "StrComp(LoginID, '" & Me.txtUsername.Value & "', 0) = 0) > 0 Then
vpwd = DLookup("strPassword", "tblUserSecurity", "StrComp(LoginID, '" & Me.txtUsername.Value & "', 0) = 0")
If StrComp(Me.txtPassword.Value, vpwd & vbNullString, vbBinaryCompare) <> 0 Then
MsgBox "Invalid Login ID or Password"
End If
'Check if user's 3 attempts are wrong then close the database with message.
If intLogAttempt = 3 Then
MsgBox "You do not have access to this database. Please contact Database Administrator." & vbCrLf & vbCrLf & _
"Application will exit.", vbCritical, "Restricted Access!"
Application.Quit
End If
'Check if Login (Userlevel) is "Employee" then go to Data entry menu with User Access Level (by default button is disabled on frmDataEntry_Navigation).
If (Me.txtSecurityLevel) = "Employee" Then
DoCmd.OpenForm "frmDataEntry_Navigation"
End If
'Check if Login (Userlevel) is "Admin" then full control all buttons & options ON (on frmDataEntry_Navigation i have enabled button based on "Admin").
If (Me.txtSecurityLevel) = "Admin" Then
DoCmd.OpenForm "frmDataEntry_Navigation"
End If
'Check if Login (UserLevel) is "User" then go to Individual record access form.
If (Me.txtSecurityLevel) = "User" Then
DoCmd.OpenForm "frmEmployeeNavigation"
End If
ErrorHandler:
End Sub
Many thanks for your help.