Here is how I have done this before. First make sure you have the code below to know the windows / AD id. Then set up your table where there is an userID column (varchar / text) then date / time column and then a Type column for either Start or End.. then you have a form on start up that on open, goes to a new record and all they have to do is click either a clock in button or clock out button. The vba code behind each will update the form with fosusername(), now() and either Start or End.
Then you can query to get the time diff and format for date to group by actual date and not time. Hope this makes sense. Should take all of an hour to create.
It is not a bad idea to also add code to lock down the db where they cannot get into the table in case you are worried about users "adjusting" their start / end times. You can prevent use of the shift key on open and also hid the ribbon to make it bullet proof.
- Option Compare Database
-
Private Declare Function apiGetUserName Lib "advapi32.dll" Alias _
-
"GetUserNameA" (ByVal lpbuffer As String, nSize As Long) As Long
-
-
Function fOSUsername() As String
-
Dim lngLen As Long, lngx As Long
-
Dim strUserName As String
-
strUserName = String$(254, 0)
-
lngLen = 255
-
lngx = apiGetUserName(strUserName, lngLen)
-
-
-
If lngx <> 0 Then
-
-
strUserName = Left$(strUserName, lngLen - 1)
-
-
fOSUsername = (Trim(Right(strUserName, 255)))
-
-
Else
-
-
fOSUsername = 0
-
-
End If
-
End Function