Code help please

mkelly

Registered User.
Local time
Today, 11:00
Joined
Apr 10, 2002
Messages
213
I have a time clock within a production database however it alowes employees to puch in more than once a day. Which in turn destroyes the production information.
Basically they go to the punch in screen and then choose their name from a combo box and then click the time in button.
I have tried the following code so they cannot punch in twice but is does not work.
Any and all help appriciated.

thanks

Private Sub Combo6_Click()
If ([employee sign-in sheet]![Date] = Date() And [employee sign-in sheet]![Employee id] > 0) Then
MsgBox "You have already Punched In Today"
End If
 
I see a couple of reasons why your code might not be working:
1 - the Date field in your [employee sign-in sheet] table is probably a Date/Time field. As Pat Hartman pointed out in another thread, it captures both the date and the time. Now, if you are comparing a date and time to just Date() which does not include a time component, then the comparison will not work as you expect.
2 - you are just checking to see if the employeeID is > 0, which I take to mean that you just want a valid employeeID. But you are not checking for a specific ID.

How about separating out the date and time components of the sign-in, then setting up the Date and EmployeeIDs as a joint primary key? That way, the table structure itself will disallow a user from signing in more than once a day? If you want to allow for that possibility, you can still split the date and time fields out and run your check on that.
 
You also have a field called Date, it's a reserved word in Access so you should change it to something else
 

Users who are viewing this thread

Back
Top Bottom