View Single Post
  #4  
Old June 8th, 2006, 06:04 AM posted to microsoft.public.access.gettingstarted
external usenet poster
 
Posts: n/a
Default Time tracking attendance

To answer your question specifically:

I would like to know if there is any way on a form that you can type in a
number e.g. 1234 press enter then in a table it adds 1234, the date and
sign
in time.Also usin the same form if you type the 1234 in again it will add
sign out time.


In short: Yes. The trick is for the form to know whether it is signing
someone in, or out. Having a method of knowing whether the sign-out time has
been entered or not that is as simple as possible would help. Using your
datastructure, here is what I would recommend.

First, instead of using "Date" and "Time In" and "Time Out" - I'd recommend
you kill the "Date" field and just use Time In and Time Out as "date" types
using the now() function. This will let you do math more easily in the
future, and will allow for easier error catching when someone scans in, but
forget to scan out. Or scans out twice etc. I'll write the following assuming
you've done that.

All your form needs is a Text Box with the "OnKeyPress" event activated.
Here is a sample of the Event. (Note: make certain you don't have a default
value for TimeOut. The Field must remain null after a Sign-In Entry for this
to work.)

Private Sub MemberID_KeyPress(KeyAscii As Integer)
Dim rst As Recordset ' This will be the Recordset of your table, or
your row.
Dim ID As String ' This will hold the Members ID
Dim Q As String ' This is a String to hold a small Query

' Define the ID
ID = Me.memberID.Value
' Determine if there is a row where the "TimeOut" has not been entered.
Q = "SELECT * FROM [TABLENAME] WHERE memberID='" & ID & "' AND
isnull(TimeOut)=true;"
Set rst = CurrentDb.OpenRecordset(Q) ' Opens a Recordset from Q

If IsNull(rst.RecordCount) = True Then ' If there is no record
rst.Close ' Close the Recordset
Set rst = CurrentDb.OpenRecordset("[TABLENAME]") ' Open the whole
Table
With rst ' In that table
.AddNew ' Add a new Row
.Fields("MemberId") = ID ' Set MemberId
.Fields("TimeIn") = Now() ' Set Date/Time of Entry
.Update ' Update the Record
End With
rst.Close ' Close the Recordset
Else
With rst ' With the single-Row Recordset
.Edit ' Edit this Row
.Fields("TimeOut") = Now() ' Set Date/Time of Exit
.Update ' Update the Record
End With
rst.Close ' Close the Recordset
End If
End Sub

Hope this Helps!

Theo Geer




"MGCurz" wrote:

My table is setup as follows MemberID,Date,TimeIn, and TimeOut. I recently
obtained a barcode wedge scanner which just acts as typin the number then
pressing enter key. In my Online Centre there are people running courses and
people can also come and go as the please but we don't have anyone on the
reception desk and i need to take note of their sign in and sign out times as
we need to produce evidence of the times to our funding agency.At the moment
im using our old database (created by an ex employee) and we have to put in
the time infomation by hand. We are usually open from 9 til 9 everyday and
usually don't leave till about 11 because we need to input data

"John Spencer" wrote:

What is your table structure? Do you have fields like WorkerID,
SignInDateTime, and SignOutDateTime? Or do you have fields like WorkerID,
ActionDateTime, and In_or_Out?

You can use defaults for your fields of Date() and Time() that will
automatically be entered when a record is created. Personnally I would use
a field that stored both the date and time - Now() - as that will make it
much easier to do calculations on the duration of time between two events
(sign in/sign out).


"MGCurz" wrote in message
...
I would like to know if there is any way on a form that you can type in a
number e.g. 1234 press enter then in a table it adds 1234, the date and
sign
in time.Also usin the same form if you type the 1234 in again it will add
sign out time.
Any help please?