Am expert had helped me with the following code to prevent duplicate entries in a table and I suppose it works but if a form is opened to review a current record and then the form is closed they get a message indicating that the record already exists. I have this code in the onclose event of the form.
How can I fix this problem? We definitely don't want duplicate records but we do want to be able to review an existing record.
Here's the code:
If DCount("*", "tblProducts", "ProdName & SizeID & FormatID & LocationID = " & Chr(34) & Me.cboProdName & Me.cboSizeID & Me.cboFormatID & Me.cboLocationID & Chr(34)) > 0 Then
MsgBox "This product already exists. Please correct your entry."
Cancel = True