On a form, I have created the following code that traps any duplicates before being entered. The expression is supposed to check and see if there is a match between the form's "ContactID" and the "fk_ContactID" value in the table "tblSolicitors". Upon running the code I get a data type mismatch error. This has worked before using text fields, but I have never tried it with number fields. What am I doing wrong?
If DCount("fk_ContactID", "tblSolicitors", "[fk_ContactID]='" & Replace(Me.ContactID, "'", "''") & "'") > 0 Then
MsgBox "This solicitor already exists.", vbExclamation, strAppName