Problem with duplicate values

  • Thread starter sike11 via AccessMonster.com
  • Start date
S

sike11 via AccessMonster.com

Hi,

I have the following code in my form:

Private Sub txtQualref_BeforeUpdate(Cancel As Integer)

Dim QR As String
Dim stLinkCriteria As String

QR = Me.txtQualref.Value

stLinkCriteria = "[txtQualref]=" & "'" & QR & "'"

If DCount("txtQualref", "tblQOEDescription",
stLinkCriteria) > 0 Then
'Undo Duplicate Entry
Me.Undo
MsgBox ("WARNING - Qual Ref: " & QR & " is
already in the database." & vbNewLine & "
RECORD DETAILS NOT ADDED!!")
End If
End Sub

The problem is that even when I input a value I know is not in the table, I
still get the error message.

Can anyone help me?

Regards,

Mary.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top