Time Clock

M

mjk

Please help!
Here's my table
EmployeeID
DeptID
ClockIn
ClockOut
Units
I created a form from the table above where all employee clocks in and out
several times a day depending on their assigments. What I want to know is how
to create one or two command button for clocking in and out after an employee
enter their employee id and dept id, the current date and time is
automatically recorded in the clock in field and do the same thing when
clocking out. Also when an employee clocks out, is it possible to have some
kind of pop up maybe another form to enter the units then clear the form for
another user. Thanks in advance...
 
A

Andrew

Please help!
Here's my table
EmployeeID
DeptID
ClockIn
ClockOut
Units
I created a form from the table above where all employee clocks in and out
several times a day depending on their assigments. What I want to know ishow
to create one or two command button for clocking in and out after an employee
enter their employee id and dept id, the current date and time is
automatically recorded in the clock in field and do the same thing when
clocking out. Also when an employee clocks out, is it possible to have some
kind of pop up maybe another form to enter the units then clear the form for
another user. Thanks in advance...

Hi

If your form has text boxes called txtClockIn and txtClockOut and
buttons called cmdClockIn and cmdClockOut then your buttons would need
to run code along these lines:

Private Sub cmdClockIn_Click()
txtClockIn.Value = now()
End Sub
------------------------------------------------
Private Sub cmdClockOut_Click()
txtClockOut.Value = now()
End Sub

Not sure what you what the other "pop-up" to do or to look like, but
you could either use an inputbox -
txtUnits = InputBox("Enter units")

or open some other form, using

DoCmd.OpenForm formName:="frmYourUnitsForm", WindowMode:=acDialog

although in this case you'll need some code to extract what the user
has entered on your pop-up form....

Hope this helps
Andrew
 
M

mjk

Thanks Andrew I'll try it and see what happens.

Andrew said:
Hi

If your form has text boxes called txtClockIn and txtClockOut and
buttons called cmdClockIn and cmdClockOut then your buttons would need
to run code along these lines:

Private Sub cmdClockIn_Click()
txtClockIn.Value = now()
End Sub
------------------------------------------------
Private Sub cmdClockOut_Click()
txtClockOut.Value = now()
End Sub

Not sure what you what the other "pop-up" to do or to look like, but
you could either use an inputbox -
txtUnits = InputBox("Enter units")

or open some other form, using

DoCmd.OpenForm formName:="frmYourUnitsForm", WindowMode:=acDialog

although in this case you'll need some code to extract what the user
has entered on your pop-up form....

Hope this helps
Andrew
 
M

mjk

Andrew I tried it and it's working so far but when I press the clock in and
clock out command button, the data doesn't dissapear. It needs to be clear
after an employee clocks in or out for the next user. Am I missing a code
maybe? Please advise...
 
A

Andrew

Andrew I tried it and it's working so far but when I press the clock in and
clock out command button, the data doesn't dissapear. It needs to be clear
after an employee clocks in or out for the next user. Am I missing a code
maybe? Please advise...











- Show quoted text -

Hi - sorry not to reply sooner...

You could try something like


Me.Dirty = False 'This saves the current record
txtClockIn = "" 'To clear out the Clock In text box
txtClockOut = "" ' To clear the ClockOut textbox
txtClockIn.SetFocus ' To put the insertion point back to the Clock in
textbox ready for the next person.


It may well be, of course, that other things need to happen in terms
of validating the data before you choose to save it, but this would at
least move you in the right direction.

Andrew
 
M

mjk

Good morning!
Do I need to insert the new code that you gave on the
form or the command button? Also on what event? Sorry I'm kind of new at this
you have to be more specific. thanks in advance.
 
A

Andrew

Good morning!
                    Do I need to insert the  new code that you gave on the
form or the command button? Also on what event? Sorry I'm kind of new at this
you have to be more specific. thanks in advance.

Well, it depends when you want the "clearing out" to happen. Assuming
that you want it to happen after the record is saved, put it after the
code which saves the record (the first code sample I gave) in the same
event procedure. In this way, if this form is unbound (ie not directly
linked to your table(s) but reliant on your code to write the data)
the logic of the "Save" button's Click event would be

1) Do any validation of the data
2) Write the data to the appropriate record of the table
3) Set the text boxes to blank
4) Set the focus back to the first text box for the next record

Of course, if this is a bound form (ie one with a direct link to the
table(s) ) then you'll need to navigate appropriately as well.
Therefore the logic might become:

1) Go to correct record for this employee / day record
- Allow the user to complete their data using the cmdClockIn /
cmdClockOut buttons
2) Do validation
3) Save the data
4) Navigate to either the appropriate record for the next employee /
day combination, or to a new record as needed
-- This will either pre-populate the text boxes with the new data (if
it's an existing record you're going to) or clear out the text boxes
(if this is a new record, which, of course, will have no data yet)
5) Set the focus to the appropriate text box, using the .SetFocus
method.

Regards
Andrew
 

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

Similar Threads


Top