Stop mouse wheel on form

Ease of Use


Version tested with


Submitted by:



will display an error message if the user tries to scroll though records 


want to stop user's of your DB from using the scroll wheel to scroll through records, or disable the mouse so it will not allow the user to scroll in a subform, to the next or previous record, this code will display an error message to the user that they are not allowed to scroll in 'this form. 


instructions for use


Private Enum wsTrigger MyWheel = 1 NotTheWheel = 2 End Enum Private mWheel As Boolean Private ValidationTrigger As wsTrigger Private Function WheelSpin() As Integer WheelSpin = mWheel Select Case ValidationTrigger Case NotTheWheel mWheel = False End Select End Function Private Sub Form_Error(DataErr As Integer, Response As Integer) If Screen.ActiveControl.Name = "UnboundTextBox" Then Response = acDataErrContinue End If End Sub Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long) On Error GoTo Sub_Err mWheel = True ValidationTrigger = MyWheel Me.UnboundTextBox.SetFocus Me.UnboundTextBox.TEXT = " " Sub_Exit: ValidationTrigger = NotTheWheel Msgbox "you can't scroll on this form, please stop scrolling", _ vbOKOnly + vbwarning, "No mouse scroll" Exit Sub Sub_Err: Resume Sub_Exit End Sub

How to use:

  1. Place an unbound textbox on your form with the name of 'unboundtextbox', color o the textbox is the same color as your form. leave the enabled proporty set to 'yes and the locked proporty set to = no,
  2. Hint: make the textbox as narrow as possable and it will be invisible to your end user
  3. and place the above code in the code section of your form.
  4. set the form proporties, on Event:
  5. On Error = [Event Procedure]
  6. Mouse Wheel = [Evdnt Procedure]

Test the code:

  1. place the code in a blank form and set the above events (mous wheel & On error) both on for proporties and the click view form and try to scroll, you'll get the error message.

Sample File:

No Attachment 

Approved by Jacob Hilderbrand

This entry has been viewed 148 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express