Customised buttons

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • panteraboy
    New Member
    • Apr 2008
    • 48

    Customised buttons

    Hi there i have been deeply frustated as last week trying to figure out how to cycle through records on a form based on a query by using images instead of command buttons . I have a customised view next and previous button. the buttons work until they go out of bounds. I am trying for example to bring the user back to the first record if the user is about to go out of the records range by pressing the next button and to the last record if the user presses the previous button and is about to go past the first record. I am only a novice user and have been playing around with recordset still me fingers have blisters. Can anyone please help me or point me in the right direction.
  • missinglinq
    Recognized Expert Specialist
    • Nov 2006
    • 3533

    #2
    I use this code for these navigation buttons. My forms are always set up with AllowAdditions set to No (I use a custom Add button as well) so at the end of the recordset Access errors out and triggers the code. You'll need to change the button names with your own, of course.

    Code:
    Private Sub Go2Next_Click()
    
    On Error GoTo Err_Go2Next_Click
    
    DoCmd.GoToRecord , , acNext
    
    Exit_Go2Next_Click:
    
    Exit Sub
    
    Err_Go2Next_Click:
    
    If Err.Number = 2105 Then
    
    DoCmd.GoToRecord , , acFirst
    
    Else
    
    MsgBox Err.Description
    Resume Exit_Go2Next_Click
    
    End If
    
    End Sub
    Code:
    Private Sub Go2Prev_Click()
    On Error GoTo Err_Go2Prev_Click
    
    DoCmd.GoToRecord , , acPrevious 
    
    Exit_Go2Prev_Click:
    
    Exit Sub
    
    Err_Go2Prev_Click:
    
    If Err.Number = 2105 Then
    
    DoCmd.GoToRecord , , acLast
    
    Else
    
    MsgBox Err.Description
    Resume Exit_Go2Prev_Click
    
    End If
    
    End Sub
    Welcome to bytes!

    Linq ;0)>

    Comment

    • panteraboy
      New Member
      • Apr 2008
      • 48

      #3
      thank you so much my head was wrecked. tried about 20 different variations including recordsets. Though it would be a lot harder to do. Im still learning lol

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        Glad we could help!

        Linq ;0)>

        Comment

        Working...