Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / August 2006

Tip: Looking for answers? Try searching our database.

Time tracking attendance

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
MGCurz - 07 Jun 2006 11:49 GMT
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?
John Spencer - 07 Jun 2006 12:37 GMT
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).

>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?
MGCurz - 07 Jun 2006 12:56 GMT
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

> What is your table structure?  Do you have fields like WorkerID,
> SignInDateTime, and SignOutDateTime?  Or do you have fields like WorkerID,
[quoted text clipped - 12 lines]
> > sign out time.
> > Any help please?
Theo Geer - 08 Jun 2006 06:04 GMT
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

> 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
[quoted text clipped - 22 lines]
> > > sign out time.
> > > Any help please?
MGCurz - 08 Jun 2006 09:50 GMT
Compile error:
Expected: end of statement

i keep getting this error message for this line;

Q = "SELECT * FROM [TABLENAME] WHERE memberID='" & ID & "' AND
isnull(TimeOut)=true;"

sorry i know nothing about codes so it may probably be an easy mistake

> To answer your question specifically:
>
[quoted text clipped - 85 lines]
> > > > sign out time.
> > > > Any help please?
Theo Geer - 08 Jun 2006 11:57 GMT
Sorry! this is my bad. There needs to be a closing parentheses after the last
quote.

Replace the line with:

Q = "SELECT * FROM [TABLENAME] WHERE memberID='" & ID & "' AND
isnull(TimeOut)=true;")

This is what I get for not testing code I post first!

Theo Geer

> Compile error:
> Expected: end of statement
[quoted text clipped - 95 lines]
> > > > > sign out time.
> > > > > Any help please?
MGCurz - 08 Jun 2006 13:17 GMT
i added the recent changes and came over another problem when i go to put in
the memberID number on the form it comes up with
Run-time error '94':
Invalid use of Null

then i click on debug and is has;
ID = Me.MemberID.Value
highlighted in yellow

> Sorry! this is my bad. There needs to be a closing parentheses after the last
> quote.
[quoted text clipped - 107 lines]
> > > > > > sign out time.
> > > > > > Any help please?
MGCurz - 08 Jun 2006 14:36 GMT
ok sorry my mistake i had mucked with the code but now my problem is that i
can record the member id but not the time in or out

> i added the recent changes and came over another problem when i go to put in
> the memberID number on the form it comes up with
[quoted text clipped - 116 lines]
> > > > > > > sign out time.
> > > > > > > Any help please?
Theo Geer - 11 Jun 2006 01:27 GMT
MGC - What is the code you're using? The code I gave you should capture the
member ID and time into your table. - Make sure that the

.fields("FIELDNAME") = now() line has FIELDNAME as the name of the actual
field in your table.

> ok sorry my mistake i had mucked with the code but now my problem is that i
> can record the member id but not the time in or out
[quoted text clipped - 119 lines]
> > > > > > > > sign out time.
> > > > > > > > Any help please?
MGCurz - 12 Jun 2006 08:56 GMT
using this code it only records the memberid;

Private Sub Form_KeyPress(KeyAscii As Integer)
Dim rst As String       '   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 = Membership.MemberID.Value
'   Determine if there is a row where the "TimeOut" has not been entered.
Q = "SELECT * FROM [Membership] 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("[Membership]")    '   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

> MGC - What is the code you're using? The code I gave you should capture the
> member ID and time into your table. - Make sure that the
[quoted text clipped - 125 lines]
> > > > > > > > > sign out time.
> > > > > > > > > Any help please?
gmenon100 - 02 Aug 2006 14:50 GMT
Hi Theo,

I was following this message to create a attendance sheet, it still gives a
compile error. The closing parentheses does not have an opening parantheses.
Can you reconfirm what is causing the compile error as I have done every
thing as you have defined.

>Sorry! this is my bad. There needs to be a closing parentheses after the last
>quote.
[quoted text clipped - 13 lines]
>> > > > > sign out time.
>> > > > > Any help please?
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.