I'm using db.execute to insert a record into a table. However, if there is a duplicate record, how do I check it? I have the dbFailOnError, but I don't know how to check it. Here's my code:
Set db = CurrentDb
strSQL = "Insert into [Time] (EmployeeID, ProjectID, WorkDate, [Hours]) values (" & EmployeeID.Value & "," & ProjectID.Value & ",#" & WorkDate.Value & "#," & Hours.Value & ")"
db.Execute strSQL, dbFailOnError
If db.RecordsAffected = 0 Then
MsgBox ("Record could not added to the Timesheet")
Exit Sub
End If
Set db = Nothing
Thanks!
Kim
Set db = CurrentDb
strSQL = "Insert into [Time] (EmployeeID, ProjectID, WorkDate, [Hours]) values (" & EmployeeID.Value & "," & ProjectID.Value & ",#" & WorkDate.Value & "#," & Hours.Value & ")"
db.Execute strSQL, dbFailOnError
If db.RecordsAffected = 0 Then
MsgBox ("Record could not added to the Timesheet")
Exit Sub
End If
Set db = Nothing
Thanks!
Kim