G
Guest
Hi, Guys!
Good morning! I have difficulty making my login form work.
Problem: When an employee clocks in or out, he will input his employee
number in the employeenumber textbox. When he presses the Enter key, the
cursor will move to the passcode textbox where he will input his unique
passcode number. When he clicks the Clock In/Clock Out button, Access should
verify the if the employee number and passcode match. If it matched, a form
showing the employee's picture, name and position will display. He press the
Enter key twice and the form will close and go back to Login Form (his time
in/time out will be set by a macro called "time in". If he enters a wrong
passcode, a message box will appear telling him his passcode is wrong and
after 3 tries and still enters a wrong passcode, the application will
shutdown.
But something's wrong. Access just opens the form showing the employee's
name, picture and position no matter what passcode you input (although the
form contains the correct employee based on the employee number that was
entered in the login form). Meaning it doesn't verify if the passcode and the
employee number are match.
Below is my code and I hope someone could help me make it work:
Private Sub cmdLogIn_click()
On Error GoTo Err_cmdLogin_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "DTR AM"
stLinkCriteria = "[EmployeeNumber]=" & Me![EmployeeNumber]
If IsNull(Me.EmployeeNumber) Or Me.EmployeeNumber = "" Then
MsgBox "Please enter your Employee I.D.", vbOKOnly, "Require Data"
Me.EmployeeNumber.SetFocus
Exit Sub
End If
If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "Please enter your password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
If Me.Password.Value = DLookup("Password", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.Password.Value
DoCmd.Close acForm, "log in", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry, but your password is invalid! Please try again",
vbOKOnly, "Invalid Password!"
Me.Password.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "I am sorry, but the system cannot verify your identification.
Please contact your System Administrator.", vbCritical, "Unidentified user
was blocked!"
Application.Quit
End If
Exit_cmdLogin_Click:
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click
End Sub
Private Sub cmdLogOut_Click()
On Error GoTo Err_cmdLogOut_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "DTR PM"
stLinkCriteria = "[EmployeeNumber]=" & Me![EmployeeNumber]
If IsNull(Me.EmployeeNumber) Or Me.EmployeeNumber = "" Then
MsgBox "Please enter your Employee I.D.", vbOKOnly, "Require Data"
Me.EmployeeNumber.SetFocus
Exit Sub
End If
If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "Please enter your password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
If Me.Password.Value = DLookup("Password", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.Password.Value
DoCmd.Close acForm, "log in", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry, but your password is invalid! Please try again",
vbOKOnly, "Invalid Password!"
Me.Password.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "I am sorry, but the system cannot verify your identification.
Please contact your System Administrator.", vbCritical, "Unidentified user
was blocked!"
Application.Quit
End If
Exit_cmdLogOut_Click:
Exit Sub
Err_cmdLogOut_Click:
MsgBox Err.Description
Resume Exit_cmdLogOut_Click
End Sub
Thank you very much in advance and God bless!
--
My sincerest thanks. . . and may the good Lord bless you always and give
you more knowledge and intelligence to share with us novice. Thank you very
much!
Resty A. Morales
Good morning! I have difficulty making my login form work.
Problem: When an employee clocks in or out, he will input his employee
number in the employeenumber textbox. When he presses the Enter key, the
cursor will move to the passcode textbox where he will input his unique
passcode number. When he clicks the Clock In/Clock Out button, Access should
verify the if the employee number and passcode match. If it matched, a form
showing the employee's picture, name and position will display. He press the
Enter key twice and the form will close and go back to Login Form (his time
in/time out will be set by a macro called "time in". If he enters a wrong
passcode, a message box will appear telling him his passcode is wrong and
after 3 tries and still enters a wrong passcode, the application will
shutdown.
But something's wrong. Access just opens the form showing the employee's
name, picture and position no matter what passcode you input (although the
form contains the correct employee based on the employee number that was
entered in the login form). Meaning it doesn't verify if the passcode and the
employee number are match.
Below is my code and I hope someone could help me make it work:
Private Sub cmdLogIn_click()
On Error GoTo Err_cmdLogin_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "DTR AM"
stLinkCriteria = "[EmployeeNumber]=" & Me![EmployeeNumber]
If IsNull(Me.EmployeeNumber) Or Me.EmployeeNumber = "" Then
MsgBox "Please enter your Employee I.D.", vbOKOnly, "Require Data"
Me.EmployeeNumber.SetFocus
Exit Sub
End If
If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "Please enter your password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
If Me.Password.Value = DLookup("Password", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.Password.Value
DoCmd.Close acForm, "log in", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry, but your password is invalid! Please try again",
vbOKOnly, "Invalid Password!"
Me.Password.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "I am sorry, but the system cannot verify your identification.
Please contact your System Administrator.", vbCritical, "Unidentified user
was blocked!"
Application.Quit
End If
Exit_cmdLogin_Click:
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description
Resume Exit_cmdLogin_Click
End Sub
Private Sub cmdLogOut_Click()
On Error GoTo Err_cmdLogOut_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "DTR PM"
stLinkCriteria = "[EmployeeNumber]=" & Me![EmployeeNumber]
If IsNull(Me.EmployeeNumber) Or Me.EmployeeNumber = "" Then
MsgBox "Please enter your Employee I.D.", vbOKOnly, "Require Data"
Me.EmployeeNumber.SetFocus
Exit Sub
End If
If IsNull(Me.Password) Or Me.Password = "" Then
MsgBox "Please enter your password.", vbOKOnly, "Required Data"
Me.Password.SetFocus
Exit Sub
End If
If Me.Password.Value = DLookup("Password", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.Password.Value
DoCmd.Close acForm, "log in", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry, but your password is invalid! Please try again",
vbOKOnly, "Invalid Password!"
Me.Password.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "I am sorry, but the system cannot verify your identification.
Please contact your System Administrator.", vbCritical, "Unidentified user
was blocked!"
Application.Quit
End If
Exit_cmdLogOut_Click:
Exit Sub
Err_cmdLogOut_Click:
MsgBox Err.Description
Resume Exit_cmdLogOut_Click
End Sub
Thank you very much in advance and God bless!
--
My sincerest thanks. . . and may the good Lord bless you always and give
you more knowledge and intelligence to share with us novice. Thank you very
much!
Resty A. Morales