Results 1 to 11 of 11
  1. #1
    Join Date
    Apr 2004
    Posts
    100

    Unanswered: record navigation

    Hi,

    if I replace the Access record navigator through my own buttons how can I avoid the error message that occurs when clicking to the next button when the end is already reached. The error says: You can't go to the specific record. I want it to say something different or just not to occur.
    THanks in advance !

  2. #2
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Check always the RecordSet.EOF if it is true then MoveFirst else MoveNext

  3. #3
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Make the same also with the Previous Button but using the RecordSet.BOF

    good luck

  4. #4
    Join Date
    Apr 2004
    Posts
    100
    THanks a lot !!

  5. #5
    Join Date
    Apr 2004
    Posts
    100
    here is my code. it still doesn't work...
    the form is called resource_detail. the code is within that form...
    it seems that the recordset doesn't recognice the eof and bof properites

    Private Sub cmdNext_Click()
    On Error GoTo Err_cmdNext_Click
    If Me.Recordset.EOF Then
    DoCmd.GoToRecord , , acLast
    Else
    DoCmd.GoToRecord , , acNext
    End If

    Exit_cmdNext_Click:
    Exit Sub

    Err_cmdNext_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_cmdNext_Click

    End Sub
    Private Sub cmdPrevious_Click()
    On Error GoTo Err_cmdPrevious_Click
    If Me.Recordset.BOF Then
    DoCmd.GoToRecord , , acFirst
    Else
    DoCmd.GoToRecord , , acPrevious
    End If

    Exit_cmdPrevious_Click:
    Exit Sub

    Err_cmdPrevious_Click:
    MsgBox Err.DESCRIPTION
    Resume Exit_cmdPrevious_Click

    End Sub

  6. #6
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    You have to define your RecordSet

    Global rs as RecordSet ' put that in a Module


    Set rs = Me.RecordsetClone 'Put it in the Form Open event

    then you can use thr rs in your code

  7. #7
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    I'll send you an example

  8. #8
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1

    Post

    Just wrote this example using the error trapping to accumplish your navigation bar.

    Hope that helps
    Attached Files Attached Files

  9. #9
    Join Date
    Apr 2004
    Posts
    100
    Thanks. But I can't fully open your sample since of an conversion error of ms access. i am using ms access 2003. I can't view the model. Maybe could you post the code?

  10. #10
    Join Date
    Oct 2003
    Location
    US
    Posts
    343
    check this code snippet. What you have to do is before you move to the next record, save the bookmark and then check its EOF. If true then you have to go back to the previously saved bookmark. this is the reason why you are still getting the error.

    varBookmark = rs.Bookmark

    rs.MoveNext
    If rs.EOF Then
    rs.Bookmark = varBookmark
    End If

  11. #11
    Join Date
    Oct 2003
    Location
    Ger
    Posts
    1,969
    Provided Answers: 1
    Quote Originally Posted by Proximus
    Thanks. But I can't fully open your sample since of an conversion error of ms access. i am using ms access 2003. I can't view the model. Maybe could you post the code?
    Sorry I don't have Acce$$ 2003 here is a converted versoin of 2000
    Attached Files Attached Files

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •