View Single Post
  #52 (permalink)  
Old 10-27-07, 15:18
pkstormy pkstormy is offline
Moderator
 
Join Date: Dec 2004
Location: Madison, WI
Posts: 3,925
Disable Mouse Scroll Wheel

This is example code to disable/enable the mouse scroll wheel from: http://www.lebans.com/mousewheelonoff.htm.

***********
Note: Another technique which works very well (without needing ANY dll or mousewheel code) is to put this code in the OnCurrent event of the form:
docmd.gotorecord,,acfirst
This works when you're ONLY dealing with 1 record on the form and want to prevent users from scrolling to a new blank record accidently.
***********

The second attachment (NoScrollMouseWheel.Zip) is a form I designed but copied the appropriate code from the MouseWheelOnOff.zip, leaving out code (and the module) I found not needed to make the technique work. I did not design any of the mousewheel code and take no credit for it.

Note: You can also try this neat little trick without using ANY mousewheel code:

If you're only dealing with 1 record on a form (ie. you use criteria to return that 1 record) and want to prevent scrolling to a new record (but need to also allow additions to the form), in the form's OnCurrent Event add this code:

docmd.gotorecord,,acFirst

This has worked very well for me and if the user tries to use the scroll, it will automatically go back to the first record! (so the user can't accidently scroll to a blank record.)

Also see this post: DBForums Code Bank
Attached Files
File Type: zip MouseWheelOnOff.zip (62.7 KB, 436 views)
File Type: zip NoScrollMouseWheel.zip (90.0 KB, 485 views)
__________________
Expert Database Programming
MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

Last edited by pkstormy; 10-11-09 at 04:04.
Reply With Quote