sk1hotpepr
Technical User
I want to have the ability to check for a duplicate entry - if duplicate, go to the existing record, else allow new entry. It seems that every entry I type in is "duplicate" even when it is not. How can I fix this - or is there a better way? any help/guidance is much appreciated. Thanks!
--------------
Code:
Private Sub SDist_BeforeUpdate(Cancel As Integer)
'if new record, check to see if School District is listed. If yes, go to record, Else allow new entry.
Dim rst As Object
Dim myStr As String
Dim stLinkCriteria As String
Set rst = Me.Recordset.Clone
myStr = Replace(Me![SDist], "'", "''")
rst.MoveFirst
rst.Find "[SDist] = '" & myStr & "'"
If Not (rst.EOF) Then 'found the record looking for
MsgBox "record exists"
Me.Undo
Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing
End Sub
----------------
--------------
Code:
Private Sub SDist_BeforeUpdate(Cancel As Integer)
'if new record, check to see if School District is listed. If yes, go to record, Else allow new entry.
Dim rst As Object
Dim myStr As String
Dim stLinkCriteria As String
Set rst = Me.Recordset.Clone
myStr = Replace(Me![SDist], "'", "''")
rst.MoveFirst
rst.Find "[SDist] = '" & myStr & "'"
If Not (rst.EOF) Then 'found the record looking for
MsgBox "record exists"
Me.Undo
Me.Bookmark = rst.Bookmark
End If
rst.Close
Set rst = Nothing
End Sub
----------------