Hello! I have two tables, one is Emp (basic employee information) and the other is EmpAudit (results from auditing file). They are linked using the EmpID, and EmpId is the primary key in both tables. I've been trying to create a re-hire button that eliminates the record in the EmpAudit table, and only deletes a few fields in the Emp table. I have used the help directory, and I think I should be using DeleteObject, but I can't figure out how to associate that one record. My code is below. This was originally done through a query, but it corrupted the record associated with the employee ID in the EmpAudit table. This is why I am trying to do it programmatically. Thanks!
If TeamNumber = 99 Then
strMessage = "Are you sure you want to re-hire and clear pertinent data? If you select ok, your action CAN NOT be undone!"
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbCancel Then
LastName.SetFocus
Cancel = True
Else
Cancel = False
stDocName = "MakeNull"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.DeleteObject , acRecord, [EmpID]
End If
End If
If TeamNumber = 99 Then
strMessage = "Are you sure you want to re-hire and clear pertinent data? If you select ok, your action CAN NOT be undone!"
intOptions = vbQuestion + vbOKCancel
bytChoice = MsgBox(strMessage, intOptions)
If bytChoice = vbCancel Then
LastName.SetFocus
Cancel = True
Else
Cancel = False
stDocName = "MakeNull"
DoCmd.OpenQuery stDocName, acNormal, acEdit
DoCmd.DeleteObject , acRecord, [EmpID]
End If
End If