time clock

B

Bill McPherson

I am trying to set up a simple time clock. I want to have the employee enter
their ID and then click on a button "TimeIn" and have it record the time in
in the table. I want them to be able to do the same for clocking in and out
for a break and then clocking out for the day using the respective buttons
and recording the current time in the table.

Thanks

Bill
 
W

Wayne-I-M

Hi Bill

I assume you have 2 fields in the table (txtTimeIn and txtTimeOut)

Of course you can improve all this with hidden controls that are visible
when certains action are done or on certain events etc. But for the basics.

Bring in the 2 time fields into your form (set the format to medium time)
Create 2 buttons (set the captions to be something like Time In and Time Out)
On the OnClick event of the Time In Buttton put this

Private Sub txtTimeIn_Click()
Me.txtTimeIn = Now()
End Sub

Do the same for the time out.

*****************
You could add the time worked to the form (if you want).
http://support.microsoft.com/Default.aspx?id=237958

*****************
You can put a clock on the form
Create a lable called BillsClock (or whatever)
Set the forms timer interval to 1000
In the forms OnTimer row create this code

Private Sub Form_Timer()
Me!BillsClock.Caption = Format(Now, "dddd, mmm d yy, hh:mm:ss AMPM")
End Sub

Of course you can change the format to whatever you want. In fact the
seconds ticking away would be a little irritating - so I would change it, I
have just given you this just so you can see how it works


Good luck with your form.

Happy new year.
 
B

Bill McPherson

Thanks for you help. I was able to make it work with one problem. I want it
to store the time permanently, but every time I open the record it
automatically changes the time to the current time whatever that may be.

Any Ideas?

Thanks

Bill
 
W

Wayne-I-M

Hi Bill

I "think" as I can't see your application that this is a table problem and
not the form.

You need to have at least 2 tables to do what you want.
If you have only one table you will either overwrite the time fields each
time you perform the operation
Or (even worse) you need to have a field for every possible time (that’s at
least 4 fields for each day the employee works with you)

The way round this is to have 2 tables.
Table 1 contains the employee details
EmployeeID
FirstName
Surname
Etc, etc

The 2nd table
TimeID
EmployeeID (this is the linking field)
DateIN
TimeIN
DateOUT
TimeOUT

Of course some people will make the TimeDate field just one - I prefer to
have 2 fields formatted in different ways (for no other reason other than
it's easier for an old chap like me to work with - of course you could have
just one IN time/Date and just one OUT Time/Date and split the contents in a
query if you need - up to you this bit)

But the main thing you "really do" need to do is store the time/date data in
another table.

Next - Your form
If it were me (there are loads of ways of doing this by the way) – I would
just create 2 forms –
Form One – this contains the Name and EmployeeID
Form Two – this contains the linking EmployeeID, TimeID Time/Date IN and OUT
and (maybe a big red button)
Form 2 would be a subform of form 1.

The employees could just tap in their ID into form 1 (make a really big box
with a really big font).
Use an AfterUpdate event on this control to go the record.

If you have linked the child / master with form 2 this will be OK.

Next the big red button will need to have an on click event

Some thing like
If the date field is today and if the TimeIN Not IsNull then me TimeOUT = Now
Else
Me TimeIN = Now

I know this is not code but you get the idea – very simple.

Off to work now (sorry having my toast and marmalade at the moment)

If you have any problems with the GoTo record and the big red button – post
back and either me or someone else will give the code.

Oh – One last thing – “don’t†store the result of any calculations (TimeIN –
TimeOUT). Show on the form or reports but it’s just extra stored data that
you can bring up at any time so it’s not worth storing.

Happy New Year and hope this helps -
 

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