A Sample VBA solution to your problem is given below:
Code:
Private Sub EmployeeNumber_LostFocus()
Dim emp, empno, db As Database
Dim rst As Recordset, criteria As String
Dim rst2 As Recordset
emp = Me![Surname]
empno = Me![Employee Number]
Set db = CurrentDb
Set rst = db.OpenRecordset("EmployeeDetails", dbOpenDynaset)
criteria = "Surname = " & emp & "AND [empno] = " & Me!EmployeeNumber
rst.FindFirst criteria
If Not rst.NoMatch Then
GoTo closedb
Else
If MsgBox("Record Not Found, add Info to Invalid Table?..", vbYesNo + vbDefaultButton2 + vbCritical, "attDate_LostFocus") = vbYes Then
'Open the Invalid Table and add the details
Set rst2 = db.OpenRecordset("Invalid", dbOpenDynaset)
With rst2
.AddNew
![FieldName1] = Me![Surname]
![FieldName2] = Me![EmployeeNumber]
![FieldName3] = Me![Answer]
.Update
End With
rst2.Close
Set rst2 = Nothing
'reset the fields to null
Me.Undo
End If
End If
closedb:
rst.Close
Set rst = Nothing
Set db = Nothing
End Sub
When you comple the Surname & EmployeeNumber field values on the 'HR Form' and leave out of the Employee Number field the program will run. It searches the Employee Details table for a match, if found then does nothing, if not a message pops up asking for confirmation to add the values entered into the Invalid table. When the user's response is Yes then adds the values from the Form controls into the Invalid Table and reset the controls of the HR Form.