Hi, Mr. Steele. Thanks for the reply. I understand what you are trying to
tell me but somehow I'm at a loss within my code. I don't know where and what
code to insert. I also realized that I need to block an employee's time out
when he failed/forgot to punch in when he came to work that day. Here's my
complete code:
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, "Employee Number
Required!"
Me.EmployeeNumber.SetFocus
Exit Sub
End If
If IsNull(Me.Passcode) Or Me.Passcode = "" Then
MsgBox "Please enter your passcode.", vbOKOnly, "Passcode Required!"
Me.Passcode.SetFocus
Exit Sub
End If
If Me.Passcode.Value = DLookup("Passcode", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.EmployeeNumber.Value
DoCmd.Close acForm, "log in", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry, but your passcode is invalid! Please try again",
vbOKOnly, "Passcode Invalid!"
Me.Passcode.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "I am sorry, but the system cannot verify your identification." &
vbNewLine & vbNewLine & _
"Please call your System Administrator.", vbCritical, "Employee
Identification Failed!"
DoCmd.Close
End If
Exit_cmdLogin_Click:
Exit Sub
Err_cmdLogin_Click:
MsgBox Err.Description, , "Bundy Clock"
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.Passcode) Or Me.Passcode = "" Then
MsgBox "Please enter your passcode.", vbOKOnly, "Required Data"
Me.Passcode.SetFocus
Exit Sub
End If
If Me.Passcode.Value = DLookup("passcode", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.EmployeeNumber.Value
DoCmd.Close acForm, "log in", acSaveNo
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox "Sorry, but your passcode is invalid! Please try again",
vbOKOnly, "Passcode Invalid!"
Me.Passcode.SetFocus
End If
intLogonAttempts = intLogonAttempts + 1
If intLogonAttempts > 3 Then
MsgBox "I am sorry, but the system cannot verify your identification." &
vbNewLine & vbNewLine & _
"Please call your System Administrator.", vbCritical, "Employee
Identification Failed!"
DoCmd.Close
End If
Exit_cmdLogOut_Click:
Exit Sub
Err_cmdLogOut_Click:
MsgBox Err.Description, , "Bundy Clock"
Resume Exit_cmdLogOut_Click
End Sub
--
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
Douglas J Steele said:
When you're checking that the Employee Number and Passcode are valid, also
check to see whether there's already an entry in the Time table for that
employee today.
Assuming that TimeID is a timestamp (date and time), compare
DateValue([TimeID]) to Date().
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
Hi Mr. Steele and Nicos!
Thank you very much for the prompt reply. Below is the scenario how
employees punch their time in/time out:
1. Login box is the startup form asking an employee number and passcode.
2. If the employee number and passcode match, Login box closes and opens a
form displaying the employee's picture, name, employee number, etc. This
form
has a subform containing the current date, time in, time out. When he
press
the Enter Key, the form closes and the Login box appears again for the
next
employee.
3. When employee number and passcode do not match, a message will display
telling the employee to retry his input and after 3 tries and still
employee
number and passcode do not match, the database closes.
The above scenario work well, but there are times employees tend to be
"playful" or something I don't know what. They type their employee number
and
passcode for several time and at the end of the day, when I am all alone
in
the office and audit the database, I am shock (literally!) to find out
what
they do. When I confront them, even issued a memo to them, they said they
didn't do it. Now I guess, you can picture my predicaments!
Now, what I want to do is to "validate" every time in/time out. An
employee
should not be allowed to punch in/out if he has already punched his time
in
that morning/afternoon.
I have tables namely "employees" with EmployeeNumber as the Primary Key;
and
"time" table with TimeID as the primary key and employeeNumber as the
foreign
key.
Please help and thank you very much!
--
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
:
Resty,
It's definitely possible, but the how depends on your design, which
you're not telling us anything about.
For instance, if there is a table with EmployeeID, WorkDate, TimeIn,
TimeOut, making a composite primary key on EmployeeID and WorkDate will
do the trick.
Nikos