Hi,
I have a main form with a subform and have created nagivational buttons for previous and next record on the subform. Code is working fine for previous button but not for next.
What I would like to be able to accomplish is when a user reaches the last record, it will not go to a blank/new record where the user can inadvertently enter data. I would like the next button to stop at the last record and then go to the first record as oppose to the default "next/blank record". I would like this button purely for navigating saved records.
Right now, the following code goes to the last record, then the next blank record, then to the first record. Any ideas... what am i missing?
Here's what I have:
Private Sub cmdNext_Click()
On Error GoTo zError
If Me.Recordset.EOF Then Exit Sub
DoCmd.GoToRecord , , acNext
Exit Sub
zError:
If Err.Number = 2105 Then
DoCmd.GoToRecord , , acFirst
End If
End Sub
Private Sub cmdPrevious_Click()
On Error Resume Next
If Me.Recordset.EOF Then Exit Sub
DoCmd.GoToRecord , , acPrevious
End Sub
Thanks in advance....
Start Free Trial