Hello.
I have two forms, one for signing in and another for signing out. The sign in form has cbo_Employee and txt_SignInTime. The sign out form has cbo_Employee and txt_SignOutTime. The table structure is:
tbl_SignIn:
Employee (Text)
Sign In Date (date)
Sign Out Date (date)
I am using the code below behind cmd_SignOut button in the form frm_SignOut to enter the sign out information into the table. This works great if the employees signs in everytime. However, when they sign out without signing in, the sign out overwrites the last sign out entry. What I need is for this to somehow check the sign in table to see if the sign out information already has an entry and if it does, it just creates a new row in the table without overwriting anything. Please help.
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim strcriterium As String
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tbl_SignIn", dbOpenDynaset)
strcriterium = "EMPLOYEE = '" & Me.EMPLOYEE & "'"
Rs.FindLast (strcriterium)
If Not Rs.NoMatch Then
Rs.AddNew
Rs.Edit
Rs("SIGN OUT DATE") = Date
Rs.Update
End If
Rs.Close
I have two forms, one for signing in and another for signing out. The sign in form has cbo_Employee and txt_SignInTime. The sign out form has cbo_Employee and txt_SignOutTime. The table structure is:
tbl_SignIn:
Employee (Text)
Sign In Date (date)
Sign Out Date (date)
I am using the code below behind cmd_SignOut button in the form frm_SignOut to enter the sign out information into the table. This works great if the employees signs in everytime. However, when they sign out without signing in, the sign out overwrites the last sign out entry. What I need is for this to somehow check the sign in table to see if the sign out information already has an entry and if it does, it just creates a new row in the table without overwriting anything. Please help.
Dim Db As DAO.Database
Dim Rs As DAO.Recordset
Dim strcriterium As String
Set Db = CurrentDb
Set Rs = Db.OpenRecordset("tbl_SignIn", dbOpenDynaset)
strcriterium = "EMPLOYEE = '" & Me.EMPLOYEE & "'"
Rs.FindLast (strcriterium)
If Not Rs.NoMatch Then
Rs.AddNew
Rs.Edit
Rs("SIGN OUT DATE") = Date
Rs.Update
End If
Rs.Close