How to stop duplicate records?
I have a subform with a button that transfers the data to another subform. At present if i attempt to transfer the same data across it appears with the standard access message.
I need to add functionality so that the button notices a duplicate record is being added. I also need an error message. Here is my code for the button.
I guess i need to add the code for the error in my Err_AddtoOrder_Click section. Does anyone know how to do this. Any help would be great.
Thanks in advance!
I have a subform with a button that transfers the data to another subform. At present if i attempt to transfer the same data across it appears with the standard access message.
I need to add functionality so that the button notices a duplicate record is being added. I also need an error message. Here is my code for the button.
Code:
Private Sub AddtoOrder_Click()
On Error GoTo Err_AddtoOrder_Click
Me.Parent.F_Order_line_subform.Form.ProductID = Me.ProductID
Me.Parent.F_Order_line_subform.SetFocus
RunCommand acCmdRecordsGoToNew
Exit_AddtoOrder_Click:
Exit Sub
Err_AddtoOrder_Click:
MsgBox Err.Description
Resume Exit_AddtoOrder_Click
End Sub
I guess i need to add the code for the error in my Err_AddtoOrder_Click section. Does anyone know how to do this. Any help would be great.
Thanks in advance!
Last edited: