Lebans Holdings 1999 Ltd.

 Home ] Up ] Feedback ] Contents ] Search ] What's New ] Files & Tips ] 

Select A Row
AutoSize TextBox

RETIRED! September 2009

I have officially retired from all things Access. Please do not send Email requesting support as I will not respond.


Keep all of your questions to the Newsgroups where everyone will benefit!



New Version 2.2 March 15, 2005                This Page Viewed:Hit Counter times.

Here is  the latest version that contains an optional parameter to turn off the MouseWheel for Subforms.MouseWheelHookA2K.zip Please note the calling convention has changed for the MouseOff function. See the code behind the sample Form.  NOTE: The A97 MouseWHeelHook.zip below DOES NOT contain the newest version of the MouseHook DLL. I am no longer updating the older A97 specific code. You can certainly use the MouseHook DLL in an A97 application.


MouseWheelHook is an MDB demonstrating how to use a MouseHook to turn off the MouseWheel. No more MouseWheel.DLL Hell!  No DLL registration required.  The MouseHook DLL is a standard Windows DLL. Do not try to Register it or set a Reference to it from within Access.  Just copy the included MouseHook.DLL into your Windows/System folder or into the same folder as your application MDB. One instance handles all Forms and SubForms so only call the functions once from a SINGLE Form.

Here is sample code that can be placed behind CommandButton controls. You could also place this code in the Load event of a single Form. Remember you need to call these functions only ONE TIME. The MouseHook will look after the MouseWheel messages for all forms that you have open now or at any time during your current session. Remember to turn the MouseWheel back on before you exit the current session!

Private Sub Command14_Click()
' Turn the MouseWheel Off
Dim blRet As Boolean
blRet = MouseWheelOFF
End Sub

Or if you will be running multiple instances of Access then you can pass an optional parameter to ask for a Global Hook. The default is FALSE. Please note the Version documentation below.

blRet = MouseWheelOFF(True)

Private Sub Command16_Click()
' Turn the MouseWheel On
Dim blRet As Boolean
blRet = MouseWheelON
End Sub

User's Tips/Hints Click Here!


Access 97 Version

MouseWheelHook97.zip is an MDB demonstrating how to use a MouseHook to turn off the MouseWheel.


Version 2.2

Yes, the version numbers on the sample MDB have finally been updated to reflect reality. What is of importance is that the DLL has a creation date of March 2005. Please note the calling convention for the MouseOff function have changed to accomodate an optional parameter to allow you to turn off the MouseWheel completely for SubForms.


Version 2.7

Please note the Optional GlobalHook BOOLEAN parameter.
Several developers asked for the MouseHook to be able to work with  multiple instances of Access. In order to accommodate this request I  have modified the function to allow the caller to  specify a thread specific(this current instance of Access only) or  a global(all applications) MouseWheel Hook.
Only use the GlobalHook param if you will be running multiple instances of Access!
blRet = MouseWheelOFF(True)

Please note this is an update from the March 09/04 release. Support has now been added for Logitech Mice. The only difference between the feature set for a MS Mouse and a Logitech Mouse is that you can scroll an open Combo control from a MS Mouse only.  Look at the code behind the sample Forms to see how to turn the MouseWheel ON or Off. You need to import into your own MDB the standard code module "modMouseHook" found in the sample MDB included in the download zip file. Bug Fix for SubForms with ScrollBars. Bug fix for SubForms without visible ScrollBars. Added support to specify an optional Global versus thread specific hook to allow for multiple instances of Access.

Version 2.6

Bug fix. The SubForm ScrollBar fix in 2.5 created a new issue for SubForms with Visible ScrollBars.

Version 2.5

Bug Fix. I don't know why but in my sample Forms I had never created a SubForm without Scrollbars. Keith Broaddrick was kind enough to point out that in a SubForm without ScrollBars the MouseWheel would still be able to scroll through the recordset. Keeping my fingers crossed that this is the last bug fix for a while!<grin>

Version 2.4

Mistakenly had commented out code to support forms in Popup view in version 2.3. Added support for Popup forms back in this release.

Version 2.3

The hook now works with all versions of Windows after Win95. (Will add WIn95 support in the next release.)

Verified the hook works with MS Access ADP Forms.

The following Bug had nothing to do with my code. Through testing I have verified this a bug with Access 97 under Windows 98 using an Intellimouse driver. It is repeatable with any MDB whether you use or do not use my hook. The Bug can result in an endless loop under a set of very specific circumstances( when the MouseWheel is rolled as fast as possible within a TextBox control). I have only ever seen this bug under the aforementioned specific system setup.

Version 2.2

Changed from a MouseHook to a MessageHook to allow for support of Logitech Mice.

Version 2.1

Now correctly handles Tab and Option Group controls. Removed Bug that would at times allow a multiline TextBox control to pass the MouseWheel messages onto the Form. Allows users to Scroll within a ComboBox control. Allows MouseWheel to work in SubForms. Leaves all non Access Form windows alone!  The logic in the DLL was completely rewritten. Works with all Access Form controls.

**Remember to remove any existing instances of the MouseHook.DLL from your system. When you call the code from your Form it first looks into your Windows/System folder for the MouseHook.DLL. If it is not found then it will look into the folder where the current MDB resides. This means if you copy the newest version of the DLL into your application folder but still have an older version in your Windows/System folder the OLDER version will be used!**



Tips from Users of MouseWheelHook


Trouble With ADP

Robert Pascale writes: Worth noting that in an Access 2000 ADP (instead of an MDB) you cannot use the "currentdb" functions.

I replaced the following line:

'hLib = LoadLibrary(CurrentDBDir() & "MouseHook.dll")
hLib = LoadLibrary(CurrentProject.Path & "\MouseHook.dll")

Might be useful to update your page.




Below is the older subclassing ActiveX DLL based method. Use the MouseWheelHook solution above instead!

NEW VERSION - October 15/2002 - Unregister and Delete all previous versions of the MouseWheel.DLL on your system before registering this new version! This version finally supports use in SubForms! Thank you to Terry Kreft for supplying the fix!


MouseWheelOnOff.zip is a database containing sample code to enable the user/develop to programmatically turn on or turn off the MouseWheel. There is no current reference in the sample MDB to the MouseWheel.DLL file. If you try to open the sample Form you will receive an error message. You must follow the instructions below, or those on the sample Form to initially register the DLL.

Here is the VB6 Source code used to build the Subclassing DLL. MouseWheelVBsource.zip


MouseWheelOnOff is a database containing sample code to enable the user/developer to:

  • Programmatically turn on or turn off the MouseWheel.
  • Expose PAINT, SCROLLBAR & MOVE events for the Form.
  • Expose a Form wide MOUSEMOVE event.


' Adapted from MS KB Article ID: Q278379

' You must set a Reference to the the file MouseWheel.DLL
' The file is included in this archive.
' After you SAVE it to a folder of your choice then you must
' go through the following steps to tell Access where this
' file is.

' 1. Open any Form in Design View, Then go to the View menu and
' select Code from the drop down menu.
' Alternatively you can open any Class or Code module.

' 2. Select the Tools->References Menu

' 3. Select the Browse Button and go to the folder where you saved
' the MouseWheel.DLL file. By default the file browser will
' only show "files of type" Type Libraries (*.olb,*.tlb).
' In order for for the
' MouseWheel.DLL file to appear you need to click on the
' "files of type" Combo and select the entry for
' Executable Files (*.exe, *.dll)



May 23, 2004 Product Update
Rich Text ActiveX control. Version 1.8

Click Here!


Mar 15, 2005 Product Update
MouseHook  Replaces the MouseWheel DLL subclassing solution. Turns On/Off the MouseWheel with one line of code. No DLL registration required. Now supports Logitech mice!

Click Here! 



Back ] Home ] Up ] Next ] 
Stephen Lebans Copyright 2009

Last Modified : 09/11/09 12:03 AM