Advertisement

05.10.2008 at 11:59AM PDT, ID: 23391949
[x]
Attachment Details

Record Navigation Button Stop on last Record

Asked by emacyam in Microsoft Access Database, Access Coding/Macros

Tags: Microsfot, Access, 2003, Record Navigation

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
[+][-]05.10.2008 at 12:07PM PDT, ID: 21540187

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: Microsoft Access Database, Access Coding/Macros
Tags: Microsfot, Access, 2003, Record Navigation
Sign Up Now!
Solution Provided By: DatabaseMX
Participating Experts: 1
Solution Grade: A
 
 
[+][-]05.10.2008 at 12:19PM PDT, ID: 21540226

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]05.10.2008 at 12:25PM PDT, ID: 21540241

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628