HI Guys,
I have a problem that occurs when you create a new record and start typing in the name field. If you change your mind and delete what you have written so that there is no longer any text in the box if you try and do anything else the Invalid use of Null error message comes up.
How can i fix this so that it stops doing this? I have the following code in the beforeupdate event of the name field...
Thanks very much! VB
I have a problem that occurs when you create a new record and start typing in the name field. If you change your mind and delete what you have written so that there is no longer any text in the box if you try and do anything else the Invalid use of Null error message comes up.
How can i fix this so that it stops doing this? I have the following code in the beforeupdate event of the name field...
Code:
Private Sub Sup_Name_BeforeUpdate(Cancel As Integer)
Dim SNM As String
Dim stLinkCriteria As String
Dim rsc As DAO.Recordset
Set rsc = Me.RecordsetClone
' If Not IsNull(Me.Sup_Name.Value) Then
SNM = Me.Sup_Name.Value
' End If
If Me.NewRecord Then
stLinkCriteria = "[Sup_Name]=" & "'" & SNM & "'"
'Check Suppliers table for duplicate Supplier
If DCount("Sup_Name", "Suppliers", _
stLinkCriteria) > 0 Then
' Undo duplicate entry
Me.Undo
'Message box warning of duplication
MsgBox "Warning the Supplier: " _
& SNM & " has already been entered." _
& vbCr & vbCr & "You will now been taken to the record.", _
vbInformation, "Duplicate Information"
'Go to record of original supplier
rsc.FindFirst stLinkCriteria
Me.Bookmark = rsc.Bookmark
End If
End If
Set rsc = Nothing
End Sub
Thanks very much! VB