Results 1 to 2 of 2
  1. #1
    caddcop is offline Advanced Beginner
    Windows XP Access 2003
    Join Date
    Feb 2011
    Location
    Upper Marlboro, Maryland, USA
    Posts
    57

    Form Navigation buttons with Goto Record#...

    I have created my own navigation buttons and a "Record Number" field, which is read-only to the users. Now they want to be able to jump to a particular record number. is this an easy thing to change?
    I tried changing the text box to locked = No and added code to its beforeUpdate event.
    Code:
    Private Sub Text_RecordNumber_BeforeUpdate(Cancel As Integer)
        If Me.Text_RecordNumber.Value > 0 And Me.Text_RecordNumber.Value < updateRecordCount(Me) Then
            Debug.Print "1 < " & CDbl(Me.Text_RecordNumber) & " < " & updateRecordCount(Me)
            DoCmd.GoToRecord , , acGoTo, CDbl(Me.Text_RecordNumber.Value)
        Else
            Me.Text_RecordNumber = Me.Text_RecordNumber.OldValue
        End If
    End Sub
    It prints the debug line, proving the value entered is within the correct range but I get a Run-time error '2105': You can't go to the specified record.


    Help?

  2. #2
    ajetrumpet is offline VIP
    Windows Vista Access 2007
    Join Date
    Mar 2010
    Location
    N/A
    Posts
    2,694
    your RECORD NUMBER argument in the DOCMD might be the wrong data type. try a LONG instead. I can guarantee that longs work. This is the code I normally used on a form requery to get back to the same record:

    Code:
    Dim I As Long
    I = Me.CurrentRecord
    Me.Requery
    DoCmd.GoToRecord acDataForm, Me.Name, acGoTo, I

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Record navigation buttons work backward
    By jonesy29847 in forum Access
    Replies: 22
    Last Post: 04-11-2011, 06:17 AM
  2. Navigation Buttons Stop My Code
    By millerdav99 in forum Programming
    Replies: 6
    Last Post: 03-18-2011, 11:13 AM
  3. Replies: 1
    Last Post: 12-22-2010, 01:28 AM
  4. Replies: 0
    Last Post: 12-12-2009, 04:45 PM
  5. Navigation Buttons not working please help
    By dinarocks74 in forum Access
    Replies: 3
    Last Post: 06-26-2009, 10:15 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums