How to Prevent Multiple Time in/Out on the same day

G

Guest

Hi, Guys! Greetings!
I have developed a payroll application using MS Access. Now my problem is, I
want to prevent our employees to have multiple Time In/Time Out. Is it
possible?

Thanks in advance!
--
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
 
D

Douglas J Steele

It's hard to give a precise answer without knowing more about the tables in
your application.

How are you accepting input for Time In/Time Out today? You should be able
to put logic in the BeforeUpdate event associated with that control to check
whether or not there's already input for the day. However, are you sure
you're never going to need to accept split shifts?
 
N

Nikos Yannacopoulos

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
 
G

Guest

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
 
D

Douglas J Steele

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().
 
G

Guest

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!)


Resty said:
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
 
D

Douglas J Steele

After the section of code:

If Me.Passcode.Value = DLookup("Passcode", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.EmployeeNumber.Value

you know that it's a valid employee number and passcode.

Assuming your Time table has EmployeeNumber and TimeID as fields in it, you
could then use something like:

If IsNull(DLookup("TimeID", "Time", "[EmployeeNumber]=" & EmployeeNumber
& _
" AND DateValue([TimeID])=" & Date()) Then

If that's true, then the employee hasn't got an entry for today. If it's
false, they have.

If you still can't follow, you're going to have to give more details such as
what your tables look like.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Resty said:
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!)


Resty said:
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
 
G

Guest

Hi, Mr. Steele! Good morning! You know what? I opened my pc and checked my
email as soon as I got up from my bed. Thanks for the help. I'll check if
it'll work later. Looks like i'm enlightened by your showing me the correct
insertion point and the correct code. Thanks a lot, man! I'll let you know if
it works. Have a nice day and God bless you all for all the help (for all
your patience and effort trying to help us.)
--
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:
After the section of code:

If Me.Passcode.Value = DLookup("Passcode", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.EmployeeNumber.Value

you know that it's a valid employee number and passcode.

Assuming your Time table has EmployeeNumber and TimeID as fields in it, you
could then use something like:

If IsNull(DLookup("TimeID", "Time", "[EmployeeNumber]=" & EmployeeNumber
& _
" AND DateValue([TimeID])=" & Date()) Then

If that's true, then the employee hasn't got an entry for today. If it's
false, they have.

If you still can't follow, you're going to have to give more details such as
what your tables look like.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Resty said:
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
 
G

Guest

Hi, Mr. Steele! Good day! Sorry but I can't make the code work. I tried to
rewrite the code the way you suggested but it still accepts punch ins
although there has been an entry for that day. Below is the structure of my
tables:

TIME TABLE
TimeID (Autonumber) Primary Key
EmployeeNumber (Number) related to "Employees" Table (relationship = one to
many)
Date (Date/Time) Default value=now()
Am_In (Date/Time) Format=short time
Am_Out(Date/Time) Format=short time; DefaultValue=#12:00:00 PM#
Pm_In(Date/Time)Format=short time; DefaultValue=#1:00:00 PM#
Pm_Out(Date/Time) Format=short time

EMPLOYEES TABLE
EmployeeNumber (Number) this is the primary key related to Time table
FirstName (Text)
MiddleName(text)
LastName(text)
Passcode (text)

Thank you very much for the patience and effort. God bless you!

Resty

--
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:
After the section of code:

If Me.Passcode.Value = DLookup("Passcode", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.EmployeeNumber.Value

you know that it's a valid employee number and passcode.

Assuming your Time table has EmployeeNumber and TimeID as fields in it, you
could then use something like:

If IsNull(DLookup("TimeID", "Time", "[EmployeeNumber]=" & EmployeeNumber
& _
" AND DateValue([TimeID])=" & Date()) Then

If that's true, then the employee hasn't got an entry for today. If it's
false, they have.

If you still can't follow, you're going to have to give more details such as
what your tables look like.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Resty said:
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
 
D

Douglas J Steele

First piece of advice: rename the Date field in your Time table. For that
matter, rename your Time table.

Date and Time are reserved words in Access, and shouldn't be used for your
own purposes.

With the names of the fields you currently have, try:

If IsNull(DLookup("TimeID", "[Time]", "[EmployeeNumber]=" & EmployeeNumber &
_
" AND [Date]=" & Date()) Then


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Resty said:
Hi, Mr. Steele! Good day! Sorry but I can't make the code work. I tried to
rewrite the code the way you suggested but it still accepts punch ins
although there has been an entry for that day. Below is the structure of my
tables:

TIME TABLE
TimeID (Autonumber) Primary Key
EmployeeNumber (Number) related to "Employees" Table (relationship = one to
many)
Date (Date/Time) Default value=now()
Am_In (Date/Time) Format=short time
Am_Out(Date/Time) Format=short time; DefaultValue=#12:00:00 PM#
Pm_In(Date/Time)Format=short time; DefaultValue=#1:00:00 PM#
Pm_Out(Date/Time) Format=short time

EMPLOYEES TABLE
EmployeeNumber (Number) this is the primary key related to Time table
FirstName (Text)
MiddleName(text)
LastName(text)
Passcode (text)

Thank you very much for the patience and effort. God bless you!

Resty

--
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:
After the section of code:

If Me.Passcode.Value = DLookup("Passcode", "Employees for Payroll",
"[EmployeeNumber]=" & Me.EmployeeNumber.Value) Then
EmployeeNumber = Me.EmployeeNumber.Value

you know that it's a valid employee number and passcode.

Assuming your Time table has EmployeeNumber and TimeID as fields in it, you
could then use something like:

If IsNull(DLookup("TimeID", "Time", "[EmployeeNumber]=" & EmployeeNumber
& _
" AND DateValue([TimeID])=" & Date()) Then

If that's true, then the employee hasn't got an entry for today. If it's
false, they have.

If you still can't follow, you're going to have to give more details such as
what your tables look like.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Resty said:
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


:

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!
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top