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:
Private Sub btnAddRec_Click()
Refresh
With CodeContextObject
On Error Resume Next
DoCmd.GoToRecord , , acNewRec
If Err.Number <> 0 Then
btnAddRec.Enabled = False
End If
End With
End Sub
Everything is OK when you just open the window and click the btnAddRec
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: 2105: «You can't go to the specified record. You may be at the end of a recordset».
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.