Follow us:

MS Access 2003: Prevent the mouse wheel from scrolling through records in a form

This MSAccess tutorial explains how to prevent the mouse wheel from scrolling through the records in a form in Access 2003 (with screenshots and step-by-step instructions).

Question: In Microsoft Access 2003/XP/2000/97, how do I prevent the mouse wheel from scrolling through records in a form?

Answer: You'll have to download the following MouseWheel.dll file and copy it to each computer that you wish to prevent scrolling.

Download MouseWheel.dll file

We recommend that you copy the MouseWheel.dll file to the following directory:

c:\Program Files\Microsoft Office\Office\

But you can copy this file to any directory that you wish. However, you should consistently copy this file to the same directory location on each computer.

Register the dll file

Next, you'll need to register the file. This is particularly important if you are running Access 97. However, if you are running Access 2000 or higher, it is still a good idea to register the file.

To do this, open a Command Prompt. Type the following command and press enter:

cd /program files/microsoft office/office

This will change your prompt to point to the directory where you've saved the MouseWheel.dll file. Now, we want to register the file. Type the following command and press enter:

regsvr32.exe mousewheel.dll

Microsoft Access

The following window should appear indicating that the MouseWheel.dll file was successfully registered.

Microsoft Access

Updating References in Access

Next, open your Access database and press Alt+F11. This will take you to the Visual Basic Editor.

Under the Tools menu, select References.

Microsoft Access

When the References window appears, click on the Browse button.

Microsoft Access

Find the MouseWheel.dll file that you saved to the computer. In this example, the MouseWheel.dll file can be found under c:\Program Files\Microsoft Office\Office\.

Click on the Open button.

Microsoft Access

Now when you return to the References window, the MouseWheel.dll file should appear with a checkmark to the left. Click on the OK button.

Microsoft Access

Add code to your form

Open your Form in design view and go to the Visual Basic editor for the form. You can do this by clicking on the button to the right of the On Open event for the Form.

When the Choose Builder window appears, highlight Code Builder and click on the OK button.

Microsoft Access

When the Microsoft Visual Basic window appears, paste in the following code:

Option Compare Database
Option Explicit

Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel

Private Sub Form_Load()
   Set clsMouseWheel = New MouseWheel.CMouseWheel
   Set clsMouseWheel.Form = Me
End Sub

Private Sub Form_Close()
   Set clsMouseWheel.Form = Nothing
   Set clsMouseWheel = Nothing
End Sub

Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
   Cancel = True
End Sub

The code should look as follows:

Microsoft Access

You can now close down the Microsoft Visual Basic editor. (save any changes, if prompted)

Save changes to your form. Now when you view your form and move the mouse wheel, the records should no longer scroll.