Results 1 to 7 of 7
  1. #1
    Sue is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    2

    Change error message "You can't go to the specified record"

    I have set up a simple switchboard that gives the user a choice of 2 forms. The second from allows the user to navigate through a questionaire for a particualar individual. I have set up some buttons to advance thru the questions and answers. When I reach the end of the dataset, I get the error message "You can't go to the specified record." I also get this message when I am on the first question and try to page backwards. Is there a way to change this error message to something more meaningful to my users - like "End of questionaire" or "Beginning of questionaire"? Please be very specific as I am a new user. Thanks.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Maybe you can set an error trap. Have you tried to debug.print the error number? If you know the error number you can create a specific trap to handle that error number.

  3. #3
    Sue is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Feb 2014
    Posts
    2
    How would I get to "debug.print"?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    I would write some VBA

    You can build an error trap and have it debug the error number. Inside the error trap you could put something like

    Debug.print err.number

    You can then view the Immediate Window for the results by pressing Ctrl+G on your keyboard

  5. #5
    NTC is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    Nov 2009
    Posts
    2,392
    It is the normal message for advancing to the next record - when that isn't possible. You could put a label on the form explaining that message. Otherwise you must go into the first & last controls that trigger this - and in the OnExit event put some code. What code? well that depends on what you want the user experience to be. One simple thing is to put the focus back to another control - so it never triggers that system message... i.e. me.OtherControlName.setfocus

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    Are you using VBA? Post the code behind the button Click event.

    Here are examples of code I use.

    The first two are from one db and simply kill the warning popup but don't tell the user what happens. This is a db I am really the only user for.

    Private Sub btnNext_Click()
    On Error Resume Next
    DoCmd.GoToRecord , "", acNext
    End Sub

    Private Sub btnPrevious_Click()
    On Error Resume Next
    DoCmd.GoToRecord , "", acPrevious
    End Sub

    In another db with many users I have a more complicated procedure. It is in a general module and is called from buttons on several forms.

    Code:
    Public Sub ViewData(strDirection)
    If Not IsNull(Form_SampleInfo.tbxViewDataFormNAME) Then
        DoCmd.Close acForm, Form_SampleInfo.tbxViewDataFormNAME, acSaveNo
    End If
    With Form_SampleInfo
    .RecordsetClone.Bookmark = .Bookmark
    Select Case strDirection
        Case "Quit"
            DoCmd.Close acForm, "SampleInfo", acSaveNo
        Case "Next"
            .RecordsetClone.MoveNext
            If Not .RecordsetClone.EOF Then
                DoCmd.GoToRecord acForm, "SampleInfo", acNext
            Else
                .RecordsetClone.MoveLast
                MsgBox "Last record."
                .btnNext.Enabled = False
            End If
            .btnPrevious.Enabled = True
        Case "Previous"
            .RecordsetClone.MovePrevious
            If Not .RecordsetClone.BOF Then
                DoCmd.GoToRecord acForm, "SampleInfo", acPrevious
            Else
                .RecordsetClone.MoveFirst
                MsgBox "First record."
                .btnPrevious.Enabled = False
            End If
            .btnNext.Enabled = True
    End Select
    End With
    End Sub
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    amrut is offline Expert
    Windows 7 64bit Access 2010 32bit
    Join Date
    Jun 2012
    Location
    Dubai
    Posts
    614
    The error number is 2105 for both the previous or next records when you are at the first or last record respectively.
    Code:
    Private Sub btnPrevious_Click()
    On Error GoTo ErrMessage
    DoCmd.GoToRecord acDataForm,"FormName",acPrevious 
    ErrMessage:
    If Err.Number = 2105 Then
    MsgBox "This is the first record"
    End If
    End Sub

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

Similar Threads

  1. Error Message 3163 "field is too small...."
    By reggieara in forum Forms
    Replies: 3
    Last Post: 01-22-2014, 08:30 PM
  2. Replies: 2
    Last Post: 11-12-2013, 07:06 PM
  3. Replies: 22
    Last Post: 10-10-2013, 12:47 PM
  4. Replies: 11
    Last Post: 11-26-2010, 10:53 PM
  5. Replies: 8
    Last Post: 11-12-2010, 10:55 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