A
AJ
Hi,
I'm trying to prevent a duplicate entry of a number in a particular
field in a form, however, whenever I enter the data it gives me the
error "Run Time Error 2001" you cancelled the previous operation.
The weird thing is that I have this exact same code running in another
form just fine. The only thing different is that one is a txt field
and the other is an integer. I've tried both DLookup and DCount as
shown in my sample code below. Any ideas?
Private Sub SO__BeforeUpdate(Cancel As Integer)
If IsNull([SO#]) Then
Exit Sub
End If
Dim varTemp1 As Variant
varTemp1 = DLookup("[SO#]", "RMA INFO", "[SO#] = Me![SO#]")
If varTemp1 = Me![SO#] Then
MsgBox "Duplicate!", vbOKOnly, "Duplicate SO Number Found"
End If
End Sub
______________________________________________________________
If DCount("*", "RMA INFO", "[SO#] = Me.SO_.Value") > 0 Then
MsgBox "You have entered a value that is already in the
table!"
Me.Undo
End If
______________________________________________________________
I'm trying to prevent a duplicate entry of a number in a particular
field in a form, however, whenever I enter the data it gives me the
error "Run Time Error 2001" you cancelled the previous operation.
The weird thing is that I have this exact same code running in another
form just fine. The only thing different is that one is a txt field
and the other is an integer. I've tried both DLookup and DCount as
shown in my sample code below. Any ideas?
Private Sub SO__BeforeUpdate(Cancel As Integer)
If IsNull([SO#]) Then
Exit Sub
End If
Dim varTemp1 As Variant
varTemp1 = DLookup("[SO#]", "RMA INFO", "[SO#] = Me![SO#]")
If varTemp1 = Me![SO#] Then
MsgBox "Duplicate!", vbOKOnly, "Duplicate SO Number Found"
End If
End Sub
______________________________________________________________
If DCount("*", "RMA INFO", "[SO#] = Me.SO_.Value") > 0 Then
MsgBox "You have entered a value that is already in the
table!"
Me.Undo
End If
______________________________________________________________