title: Add new record to the table by click on the button in Microsoft Access
body: <p>In my MS Access form I want to implement a separate button, that adds a new record to the table. In order to do that I added a button and attached to this button an event:</p>
  
  <pre><code>Private Sub btnAddRec_Click()
      Refresh
      With CodeContextObject
      On Error Resume Next
      DoCmd.GoToRecord , , acNewRec
      If Err.Number &lt;&gt; 0 Then
      btnAddRec.Enabled = False
      End If
      End With
  End Sub
  </code></pre>
  
  <p>Everything is OK when you just open the window and click the <code>btnAddRec</code> button, the problem is when you first of all perform the navigation through existed records and only after that click on this button. I got the runtime error: <strong><em>2105: «You can't go to the specified record. You may be at the end of a recordset»</em></strong>.</p>
  
  <p>How to solve the issue, I need to have ability to add the new record on click on specific button, no matter, have I walked or not walked through the records before.</p>