Have this code to check for duplicates and if I change my BoxID to a text and run it as a string it works, but I need it to be a Long Integer. The data mismatch I am getting is underlined there are two. Thanks
Code:
Private Sub BoxID_AfterUpdate()
'*********************************
'Code sample courtesy of srfreeman
'*********************************
Dim BoxID As Integer
Dim stLinkCriteria As Integer
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
BoxID = Me.BoxID.Value
[B][U]stLinkCriteria = "[BoxID]=" & "'" & BoxID & "'"[/U][/B]
'Check CONTAINR table for duplicate BoxID
[U][B]If DCount("BoxID", "CONTAINR", _
stLinkCriteria) > 0 Then[/B][/U] 'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning BoxID " _
& BoxID & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original BoxID
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
Comment