I have created a form and need to be able to delete employees from a table. I built a command button using the wizard and this is the current vb code-
But when I click on the button I get a message saying it would create duplicate data in the table. What am I doing wrong?
Code:
Private Sub cmdDeleteEmployee_Click()
On Error GoTo Err_cmdDeleteEmployee_Click
DoCmd.RunCommand acCmdSelectRecord
DoCmd.RunCommand acCmdDeleteRecord
Exit_cmdDeleteEmployee_Click:
Exit Sub
Err_cmdDeleteEmployee_Click:
MsgBox Err.Description
Resume Exit_cmdDeleteEmployee_Click
End Sub
But when I click on the button I get a message saying it would create duplicate data in the table. What am I doing wrong?