Enabled scrolling in sub report? RRS feed

  • Question

  • For some reason I can't scroll through my subreport with my mouse wheel. I found a code online, but it's full of errors. Any thoughts?

        Dim r As Long
        If Not Me.Dirty Then
            Do While r < Abs(Count)
                If (Count < 0) And (Me.CurrentRecord >= 1) Then
                    DoCmd.GoToRecord , , acPrevious, 1
                ElseIf (Count > 0) then 'And (Me.CurrentRecord < Me.Count) Then 'This said Me.RecordSet.RecordCount but that was wrong. Also looking at the count here seems to just mess things up actually. 
                    DoCmd.GoToRecord , , acNext, 1
               End If
               r = r + 1
        End If

    Tuesday, September 10, 2019 6:30 PM


All replies

  • If you go to VBE  ( the code editor) can you scroll with your mouse wheel?
    Tuesday, September 10, 2019 6:38 PM
  • Yes... I can also scroll through my list boxes, etc.
    • Edited by InnVis Tuesday, September 10, 2019 6:40 PM
    Tuesday, September 10, 2019 6:40 PM
  • If its a "report" don't scroll on "each" record...unless i am missing something (report is pretty much like an image)

    Try the arrow keys

    Tuesday, September 10, 2019 6:52 PM
  • Found a great API online. 
    • Marked as answer by InnVis Tuesday, September 10, 2019 9:21 PM
    • Edited by InnVis Tuesday, September 10, 2019 9:22 PM
    Tuesday, September 10, 2019 7:07 PM
  • Hi InnVis,

    Are you talking about not being able to scroll a report that is embedded in a form? If so, perhaps you could share the code you used or provide a link to the API you used.

    Thank You,

    Peter Hibbs.

    Sunday, September 15, 2019 6:56 PM
  • Of course, this was actually a code to scroll through extended textboxes, but I modified it to be used on embedded subreports and subforms.

    Option Compare Database
    Option Explicit
    Private Const sModName = "mod_ScrollingTextBox"
    'Scrolling Constants
    Public Const WM_VSCROLL = &H115
    Public Const WM_HSCROLL = &H114
    Public Const SB_LINEUP = 0
    Public Const SB_LINEDOWN = 1
    Public Const SB_PAGEUP = 2
    Public Const SB_PAGEDOWN = 3
    Public Declare PtrSafe Function apiGetFocus Lib "user32" Alias "GetFocus" _
                                         () As Long
    Public Declare PtrSafe Function SendMessage Lib "user32" Alias "SendMessageA" _
                                        (ByVal hwnd As Long, ByVal wMsg As Long, _
                                         ByVal wParam As Integer, _
                                         ByVal lParam As Any) As Long

    This is how it's called on the mousewheel event, I commented out the part that worked only with textboxes:

    Private Sub Report_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
        On Error GoTo Error_Handler
        Dim i                     As Long
            For i = 1 To Abs(Count)
                SendMessage apiGetFocus, WM_VSCROLL, IIf(Count < 0, SB_LINEUP, SB_LINEDOWN), 0&
                'The following line would flip the scrolling direction of the mousewheel
    '            SendMessage CtlHwnd, WM_VSCROLL, IIf(Count < 0, SB_LINEDOWN, SB_LINEUP), 0&
        On Error Resume Next
        Exit Sub
        MsgBox "The following error has occured" & vbCrLf & vbCrLf & _
               "Error Number: " & Err.Number & vbCrLf & _
               "Error Source: " & sModName & "\Form_MouseWheel" & vbCrLf & _
               "Error Description: " & Err.Description & _
               Switch(Erl = 0, "", Erl <> 0, vbCrLf & "Line No: " & Erl) _
               , vbOKOnly + vbCritical, "An Error has Occured!"
        Resume Error_Handler_Exit
    Monday, September 16, 2019 12:13 PM
  • Hi InnVis,

    Thanks very much, that works for me as well.

    Peter Hibbs.

    Monday, September 16, 2019 2:01 PM
  • Yay, thanks for the points!
    Monday, September 16, 2019 4:18 PM
  • I'm using your code line for line and running into an error on a subform.  This code works in a new access database, so what troubleshooting would you recommend? 
    Monday, September 30, 2019 9:35 PM
  • Sorry for the late reply. So you're saying it's not working on your database, but if you make a new blank database it works? Perhaps it could be the version of the Access file or the add-ons running.
    Tuesday, October 22, 2019 3:53 PM