Setting and moving to a bookmark
<p>I have an error message on a form that checks for an existing SSN on the BeforeUpdate event of a text box. If it already exists in the database, the user is given a message box to this effect, and has the option to go to the existing record. I'm using <a href="http://www.databasedev.co.uk/duplicates.html" rel="nofollow noreferrer">this example code here</a>. My code is below.</p>
<pre><code>Private Sub txtSocialSecurityNumber_BeforeUpdate(Cancel As Integer)

    'check for existing SSN
    Dim SSN As String
    Dim strLinkCriteria As String
    Dim rsc As Recordset
    
    Set rsc = Me.RecordsetClone
    
    SSN = Me.txtSocialSecurityNumber.Value
    strLinkCriteria = &quot;[SocialSecurityNumber] = &quot; &amp; &quot;'&quot; &amp; SSN &amp; &quot;'&quot;
    
    'look for duplicates
    If DCount(&quot;SocialSecurityNumber&quot;, &quot;Person&quot;, LinkCriteria) &gt; 0 Then
        'Undo duplicate entry
        Me.Undo
        'error message
        intResponse = MsgBox(&quot;Social Security Number &quot; &amp; SSN &amp; &quot; already exists in database.&quot; &amp; _
            vbCrLf &amp; vbCrLf &amp; &quot;Would you like to view the record?&quot;, vbYesNo, &quot;Duplicate SSN&quot;)
            If intResponse = vbYes Then
                'go to record
                rsc.FindFirst strLinkCriteria
                Me.Bookmark = rsc.Bookmark
            ElseIf intResponse = vbNo Then
                Exit Sub
            End If
    End If
    
    Set rsc = Nothing

End Sub
</code></pre>
<p><strike>According to this code, and several other examples I have looked up, it seems like I'm doing everything right, but I must not be because when I try to run the code and go to the existing record, I get the error &quot;Run-time error '424': Object Required&quot;. When I debug, the row <code>rst.FindFirst strLinkCriteria</code> is highlighted, and hovering over it gives me the text <code>strLinkCriteria = &quot;[SocialSecurityNumber] = '123456789'&quot;</code> (123456789 is a known sample SSN in my database).</strike> Thank you to Sergey S. for pointing out the spelling error that fixed this section.</p>
<p>When I tell the message box to go to the record with the existing SSN, it gives me <code>Run-time error '3021': No current record</code>. Debug highlights the line <code>Me.Bookmark = rsc.Bookmark</code> with the message <code>rsc.Bookmark = &lt;No current record.&gt;</code>. So it sounds like I'm not assigning the bookmark correctly.</p>
<p>I've never used bookmarks before, so I'm not really sure what I'm doing wrong here. Any help would be appreciated.</p>