Results 1 to 6 of 6
  1. #1
    apk19 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2015
    Posts
    30

    Run time error 2105 at end of continuous form

    Hi all,



    I have a continuous subform that acts as a search form. You can scroll through the records but when getting the to end of the recordset, I get a silly runtime 2105 error as there is no record after the last.

    Code:

    HTML Code:
    Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
    
    If (Count < 0) And (Me.CurrentRecord > 1) Then
    
    DoCmd.GoToRecord , , acPrevious
    
    ElseIf (Count > 0) And (Me.CurrentRecord <= Me.Recordset.RecordCount) Then
    
    DoCmd.GoToRecord , , acNext
    
    End If
    
    End Sub
    Any suggestions on how I can just have the mouse wheel do nothing at the end instead of the error?

  2. #2
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    This added error handler will ignore the error:

    Code:
    Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
        On Error GoTo Error_Handler
        If (Count < 0) And (Me.CurrentRecord > 1) Then
            DoCmd.GoToRecord , , acPrevious
        ElseIf (Count > 0) And (Me.CurrentRecord <= Me.Recordset.RecordCount) Then
            DoCmd.GoToRecord , , acNext
        End If
    Error_Handler_Exit:
        On Error Resume Next
        Exit Sub
    Error_Handler:
        Select Case Err
            Case 2105   'ignore
            Case Else
                MsgBox "Error " & Err.Number & " (" & Err.Description & ") in procedure Form_MouseWheel" & "."
        End Select
        Resume Error_Handler_Exit
    End Sub

  3. #3
    apk19 is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    May 2015
    Posts
    30
    Thanks davegri, but I still get the runtime error.

    The debugger highlights: DoCmd.GoToRecord , , acNext

  4. #4
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,858
    Check the values of Me.CurrentRecord and Me.Recordset.RecordCount ?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  5. #5
    davegri's Avatar
    davegri is offline Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,388
    Quote Originally Posted by apk19 View Post
    Thanks davegri, but I still get the runtime error.

    The debugger highlights: DoCmd.GoToRecord , , acNext
    Edit: I tested your original code and it works fine with no error at all.

    Something else must be going on.
    The fact that you get a debug break at all with the error handler in place makes no sense.
    Perhaps you'll have to upload your DB here for analysis.
    Last edited by davegri; 02-05-2021 at 05:21 PM. Reason: See edit

  6. #6
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    Check to see if you have selected "Break on all errors" in vb editor options.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

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

Similar Threads

  1. Replies: 5
    Last Post: 12-18-2019, 04:54 PM
  2. Run-time error 2105
    By flantrains in forum Programming
    Replies: 3
    Last Post: 12-09-2019, 12:53 AM
  3. Replies: 1
    Last Post: 01-10-2014, 09:51 AM
  4. Replies: 10
    Last Post: 10-22-2013, 07:35 AM
  5. Replies: 1
    Last Post: 06-04-2012, 03:37 PM

Tags for this Thread

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