G
Guest
Hi i am using some code that is supposed to check if a field (serial number)
has been entered in twice in two different records and i am keep receiving
the error invalid use of null. Here is my code. I would appreicate any help.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim SERIAL_NO As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SERIAL_NO = Me.SERIAL_NO.Value
stLinkCriteria = "[Serial_NO]=" & "'" & SERIAL_NO & "'"
'check form details tables for duplicate SERIAL_NO
If DCount("Serial_NO", "Hardware", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Serial Number " _
& SERIAL_NO & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Serial Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub
has been entered in twice in two different records and i am keep receiving
the error invalid use of null. Here is my code. I would appreicate any help.
Private Sub Form_BeforeUpdate(Cancel As Integer)
Dim SERIAL_NO As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
SERIAL_NO = Me.SERIAL_NO.Value
stLinkCriteria = "[Serial_NO]=" & "'" & SERIAL_NO & "'"
'check form details tables for duplicate SERIAL_NO
If DCount("Serial_NO", "Hardware", stLinkCriteria) > 0 Then
'Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning Serial Number " _
& SERIAL_NO & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", vbInformation _
, "Duplicate Information"
'Go to record of original Serial Number
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
Set rsc = Nothing
End Sub