duplicates notification

  • Thread starter Thread starter DavdB
  • Start date Start date
D

DavdB

Is there a way that I can have a field in a form notify
me if there are any duplicates, but still allow them?
 
Yes, be sure that duplicates are allowed for the field in
its table and add the following code in the After Update
event for the field in your form:

Private Sub Title_AfterUpdate()
On Error GoTo Err_Title_AfterUpdate
If DCount
("[YourDataField]", "[YourQueryOrTableName]", "[YourDataFi
eld]=Forms!frmYourFormName![YourDataField]") <> 0 Then
Beep
MsgBox "Duplicate thing! Change the thing name or
click on the UNDO button" _
& " and enter an different thing.",
16, "Duplicate thing"
End If

Exit_Title_AfterUpdate:
Exit Sub

Err_Title_AfterUpdate:
MsgBox Error$
Resume Exit_Title_AfterUpdate

End Sub

HTH, Denny G.
 
Back
Top