Results 1 to 3 of 3
  1. #1
    Sesame7883 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    2

    Rich Text Box isn’t scrolling

    Hello, I have created a form that has a rich text field with a large amount of text that I need to scroll through. But when I hover my mouse over the box and scroll, nothing happens. Clicking into the field and then scrolling also does nothing. When I scroll, in the lower left corner of the window, a message flashes briefly that says something like "… page, press ctrl-break to stop." Also worth noting that if I click into the field, using page up and page down keys does work to scroll.

    Any advice?

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,428
    I presume by 'when I hover my mouse over the box and scroll' you mean you are using the mousewheel. If so you need to use a couple of API's. The below assumes you are using access 2007 or later.


    At the top of the form module put

    Code:
    'Scrolling Constants
    Private Const WM_VSCROLL = &H115
    Private Const SB_LINEUP = 0
    Private Const SB_LINEDOWN = 1
    
    
    
    Private Declare PtrSafe Function GetFocus Lib "USER32" () As LongPtr
    Private Declare PtrSafe Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hWnd As LongPtr, ByVal wMsg As Long, ByVal wParam As LongPtr, lParam As Any) As LongPtr
    
    Function useMouseWheel(wCount As Long)
    Dim i  As Long
    
        For i = 1 To Abs(wCount)
        
            SendMessage GetFocus, WM_VSCROLL, IIf(wCount < 0, SB_LINEUP, SB_LINEDOWN), 0&
        
        Next
    
    End Function
    and call it in the form on mouse wheel event - put the name of richtext control where indicated
    Code:
    Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
    'note to set the active control, it is necessary to click on the control to make it the active control  
    
         If ActiveControl.Name = "nameOfRichTextControl" Then useMouseWheel (Count)
    
    End Sub

  3. #3
    Sesame7883 is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2022
    Posts
    2
    That did it, thank you so much!

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

Similar Threads

  1. Setting Font size in text box, set to rich text
    By Miles R in forum Programming
    Replies: 5
    Last Post: 09-01-2021, 11:55 AM
  2. Replies: 8
    Last Post: 06-18-2021, 04:22 PM
  3. Rich text field not displaying rich text properly
    By CodeLiftSleep in forum Access
    Replies: 4
    Last Post: 01-24-2018, 10:59 AM
  4. Replies: 3
    Last Post: 06-04-2017, 01:02 PM
  5. Replies: 4
    Last Post: 08-07-2015, 07:49 AM

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