Trying to disallow duplicate entries in a text fiel on a form
I'm using this code in an attempt to disallow duplicate entries in a form field. But I get an error... "Data type mismatch in criteria expression". Note: Serial is a text field in the table.
Private Sub txtSerial_BeforeUpdate(Cancel As Integer)
Dim strCriteria As String strCriteria = "Serial = " & Me.txtSerial & "" If DCount("Serial", "tblEquipment", strCriteria) > 0 Then Me.Undo MsgBox "Warning: Serial " & txtSerial & " already exists." & vbCr & vbCr & "You cannot enter duplicate serial numbers.", vbInformation, "Duplicate Information" Cancel = True End IfEnd Sub