Hi,
I am facing a problem while preventing duplicate value in field "CID". As per below code, it response good when any duplicate value enters in CID field, but it also responses the same msg while entering new CID value.
Please help me to find the problem. thanks in advance.
I'm using Access2003.
================================================== ========
Private Sub CID_BeforeUpdate(Cancel As Integer)
Dim SID As String
Dim stLinkCriteria As String
SID = Nz(Me.Cid.Value, "")
stLinkCriteria = "Cid = " & "'" & SID & "'"
If DCount("Cid", "tblCustomerSale", stLinkCriteria) > 0 Then
MsgBox "Duplicate Customer ID.", , "Error"
Cancel = True
End If
End Sub
================================================== =======