7/22/2012

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

Question: In 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


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

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.


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


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.


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.

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.


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
    clsMouseWheel.SubClassHookForm
End Sub
Private Sub Form_Close()
    clsMouseWheel.SubClassUnHookForm
    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:


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.

1 comment:

  1. 5 dni temu — Automatic Roulette may be very comparable in its features to different types of this sport, however right here have the ability to|you possibly can} place the best bets and hit the jackpot. Each arm rotates around the face in a sophisticated movement spanning 10 minutes in whole. And whereas it's intricate, even for the 6 God's requirements, the Astronomia Casino is par 네온카지노 for the course for Jacob & Co. In the previous, the Manhattan-based wristwatch retailer has produced equally complex timepieces inspired byexcavator trucksandoil pumps,and even one that plays the complete theme tune of The Godfather. You are confronted with a table with 36 squares, numbered one to 36, with the addition of a single or additionally double zero square on top.

    ReplyDelete