If you are at the last record, error 2105 occurs (can't go to the specified record)
The error handling below deals with that
Code:
Private Sub cmdNext_Click()
On Error GoTo Err_Handler
DoCmd.GoToRecord , , acNext
Exit_Handler:
Exit Sub
Err_Handler:
If Err = 2105 Then
'already at last record - exit without message
Else
MsgBox "Error " & Err.Number & " in cmdNext_Click procedure : " & Err.Description, vbOKOnly + vbCritical
End If
Resume Exit_Handler
End Sub
I normally have 4 buttons cmdFirst, cmdLast, cmdNext, cmdPrev
I add code so that if I'm on the last record, cmdNext & cmdLast are disabled
Similarly on first record cmdFirst & cmdPrev are disabled
Effective error handling is VERY useful & its worth the time learning it many times over
The attached file lists all Access error codes together with their description
Most are very obscure but some like error 94 - invalid use of null - are common
HTH