Below is the code I have that adds a new record each time an employee logs out or in. What I am tring to do is rather than it adding a new record I want it to edit the time record of the employee clocking in or out. I am having a problem figureing out how to find and edit the record I need with the code below. I know the Set rst should open the table find the record the ssn they enter and edit it. ANy help
Private Sub clock_Click()
If Me.SSN = DLookup("[SSN]", "Employees") Then
'--
Set rst = CurrentDb.OpenRecordset("Time", dbOpenDynaset)
rst.AddNew
rst![SSN].Value = Me.SSN 'use the name of the field for your date in your table
rst![Name].Value = DLookup("[Name]", "Employees", "[SSN]='" & Me.[SSN] & "'")
rst![Time].Value = Now()
rst.Update
rst.Close
'--
DoCmd.Close
Else
MsgBox "No Employee On File"
Me.SSN.SetFocus
End
End If
End Sub
Private Sub clock_Click()
If Me.SSN = DLookup("[SSN]", "Employees") Then
'--
Set rst = CurrentDb.OpenRecordset("Time", dbOpenDynaset)
rst.AddNew
rst![SSN].Value = Me.SSN 'use the name of the field for your date in your table
rst![Name].Value = DLookup("[Name]", "Employees", "[SSN]='" & Me.[SSN] & "'")
rst![Time].Value = Now()
rst.Update
rst.Close
'--
DoCmd.Close
Else
MsgBox "No Employee On File"
Me.SSN.SetFocus
End
End If
End Sub