Another mousewheel solution

jet46

Registered User.
Local time
Today, 08:58
Joined
Sep 22, 2004
Messages
25
There is another solution to the mousewheel changing records problem. Its alot more simple than the dll fix.

Create a textbox on your form with the following properties:
Name: NoMouseWheel
Backstyle: Transparent
Backcolor: 2147483633
Borderstyle: Transparent
Special Effect: flat
Default Value: " "
Validation Rule: WheelSpin()=False
Validation Text: You cannot use the mouse wheel to change records
Enabled: Yes
Locked: No

Then place the following code in your forms module:

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_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo Sub_Err
mWheel = True
ValidationTrigger = MyWheel
Me.NoMouseWheel.SetFocus
Me.NoMouseWheel.TEXT = " "
Sub_Exit:
ValidationTrigger = NotTheWheel
Exit Sub
Sub_Err:
Resume Sub_Exit
End Sub

_____________________________

And its that easy,

John
 
Thanks

I know this was posted a long time ago but needed this fix as a customer of mine was corrupting records with his habit of using the roller

Cheers saved me a lot of work
 
I would just like to know if this code and text box disables the mouse wheel in the form? I cannot figure out what exactly it does and also if I have to put the text box in a special place for this to work.

Thanks.
 
It doesn't actually disable the wheel, however it causes a validation error when the mouse wheel is used, causing the validation error message to come up. This prevents the mouse wheel action from carrying out and it doesn't change records. Basically, what happens to the user when they use the mouse wheel is they get an error message "You cannot use the mouse wheel to change records" and it doesn't change records. So it acts as if the wheel is disabled.

The field doesn't need to be places andwhere special, just make sure its visible and enabled properties are true, and locked is false. On my forms, I have made it very small and transparent so you don't actually see it.
 
For some reason, it is not working at all for me. I have done exactly as you say and it isnt working. I think it is because of where I put my code. I placed it in General of VBA. Is this correct?
 
I prefer to let my users "use" their mouse wheel as long as the current record is not dirty [modifed yet not saved]. If it is, then I prevent the user from moving to another record until they either click my custom Save button or Undo the changes to the current record.

Check this thread out... A better mouse trap? and see how I do it. Not too different from the above code but not as restrictive since most users like to navigate with their mouse wheel.
 

Users who are viewing this thread

Back
Top Bottom