Mouse wheel scroll in memo field on form

  • Thread starter Thread starter rbuc
  • Start date Start date
R

rbuc

Guest
I have recently employed MS Knowledge Base article 278379 code to prevent the mouse wheel from scrolling through records in a form. But what I want to be able to do is to use the wheel to scroll up and down the text in a memo field of a single record in a form. How can I set this up?
 
So to handle this, we would... Class? Anyone? Anyone?

I see this post has gone a good 3+ years without a reply, so I'm not sure if the original thread creator even cares anymore, but I'm curious myself. Can anyone out there answer this? I'm finding multiple posts and articles on how to completely disable the mousewheel, but not any on how to simply change its behavior so it scrolls up and down (as it does in pretty much any other program :rolleyes:).

My MAIN concern is that I can scroll up and down the entire form, but having the ability to scroll the contents of a memo field would also be very handy. Scrolling through records rather than up and down a page using the mousewheel is counterintuitive to the average user, who expects an interface more akin to their familiar web browser, and who (realistically) tend to be the people for whom we actually design these forms.

Soooo... any chance someone's got a solution for this? It'd sure be appreciated.
 
I am going to give this a BIG BUMP! as I desperately need to know how to be able to scroll through a memo field. Please, all you experts out there we need your help. Personally, I am fine with having to set the focus to the memo field first and then be able to scroll, but I know others want to be able to scroll through the whole record(if it doesn't fit on one page). Thanks for your help:)
 
Re: Mouse wheel scroll in memo field on form - SOLVED

Hello Everyone,

I've been looking for this same answer for a long time and resorted to developing a work-around. Here it is:

First, follow MS's steps to disable the scroll wheel using the second method about half way down the page, which is titled "Creating the MouseWheel Event Completely Within Microsoft Access." A link to that article can be found here: http://support.microsoft.com/kb/278379.

At this point, test your implementation of MS's code to make sure it works so far. You should get the message "You cannot use the mouse wheel to scroll records" whenever the scroll wheel is moved.

In the "basSubClassWindow" module, declare a new public variable as a long integer.

Code snippet:

[
Public Const GWL_WNDPROC = -4
Public Const WM_MouseWheel = &H20A
Public lpPrevWndProc As Long
Public CMouse As CMouseWheel

Public wParamTest As Long

]

Assign the value of wParam to your variable in the public function "WindowProc()" BEFORE the Select Case.

Code snippet:

[
Public Function WindowProc(ByVal hwnd As Long, _
ByVal uMsg As Long, _
ByVal wParam As Long, _
ByVal lParam As Long) As Long

'Look at the message passed to the window. If it is
'a mouse wheel message, call the FireMouseWheel procedure
'in the CMouseWheel class, which in turn raises the MouseWheel
'event. If the Cancel argument in the form event procedure is
'set to False, then we process the message normally, otherwise
'we ignore it. If the message is something other than the mouse
'wheel, then process it normally

wParamTest = wParam

Select Case uMsg
Case WM_MouseWheel

CMouse.FireMouseWheel

If CMouse.MouseWheelCancel = False Then
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End If

Case Else
WindowProc = CallWindowProc(lpPrevWndProc, hwnd, uMsg, wParam, lParam)
End Select
End Function

]

Finally, open the code for your form's class objects. Comment out the message box telling you you can't use the mouse wheel in the private sub "clsMouseWheel_Mousewheel()". Change the subroutine as follows:

Code snippet:

[
Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
'This is the event procedure where you can
'decide what to do when the user rolls the mouse.
'If setting Cancel = True, we disable the mouse wheel
'in this form.

' MsgBox "You cannot use the mouse wheel to scroll through records."

If wParamTest < 0 Then
SendKeys "{DOWN 2}"
ElseIf wParamTest > 0 Then
SendKeys "{UP 2}"
End If
Cancel = True

End Sub

]

Optionally, you can adjust the number of lines the mouse wheel "scrolls."
 
Last edited:
You'd can write this code in the "On Mouse Wheel" Event of the form that it has a CombBox or MemoBox. The code below uses SendKeys, which is reputed to be flaky (but it generally works OK most of times for most of us!) :)


Code:
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
    Dim i As Long
    Dim s As String
    If Me.ActiveControl.Name = "Staff_Details" Then ' >>>> replace with name of Textbox or Memobox
        If Count > 0 Then
            For i = 1 To Count
            s = s & "{DOWN}"
            Next i
        Else
            For i = 1 To -Count
            s = s & "{UP}"
            Next i
        End If
        SendKeys s
    End If
End Sub
'_____________________________________​
Note: This code can move the cursor between the lines, not scrolling the page!
For this matter I know another code if you want.
 
Last edited:
Kasy, pls read first the Post Date, the last post was 2008.
 
You'd can write this code in the "On Mouse Wheel" Event of the form that it has a CombBox or MemoBox. The code below uses SendKeys, which is reputed to be flaky (but it generally works OK most of times for most of us!) :)


Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)​
Dim i As Long​
Dim s As String​
If Me.ActiveControl.Name = "Staff_Details" Then ' >>>> replace with name of Textbox or Memobox​
If Count > 0 Then​
For i = 1 To Count​
s = s & "{DOWN}"​
Next i​
Else​
For i = 1 To -Count​
s = s & "{UP}"​
Next i​
End If​
SendKeys s​
End If​
End Sub​
'_____________________________________​
Sorry guys, I wrote an arranged code line by line, but the editor of this page changed it to his liking! :(
That is because you did not use code tags? :(
 
Just as an aside, in later version it works without the need for code anyway
 

Users who are viewing this thread

Back
Top Bottom