Answered by:
Enabled scrolling in sub report?

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 Loop End If
Answers
All replies
-
-
-
-
-
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& Next Error_Handler_Exit: On Error Resume Next Exit Sub Error_Handler: 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
-
-
-
-