Disabling a Wheel Mouse

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there any way to programmatically disable the wheel scroll function for
end-users when they are using an Access application

Thanks
 
This works for me in Access XP. This works in Single Form, not Continuous
Forms.

HTH,
Debbie


Add a Text Box on your form:

Name = NoMouseWheel
Default Value = " "
Validation Rule = WheelSpin() = False
Validation Text = You can't change records using your mouse wheel. (this can
be left out if you don't want a message)
Visible = Yes
Enabled = Yes
Locked = No
Tab Stop = No
Back style = Transparent
Back Color = -2147483633 (or whatever color your form is)
Special Effect = Flat
Border style = Transparent

FORM EVENTS:

On Mouse Wheel: [Event Procedure]
----------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo GotError
mWheel = True
ValidationTrigger = TheWheel
Me.NoMouseWheel.SetFocus
Me.NoMouseWheel.Text = " "

ExitSub:
ValidationTrigger = NotTheWheel
Exit Sub

GotError:
MsgBox Err.Number & vbCrLf & Err.Description
Resume ExitSub
End Sub
----------------------------------------------------------------------------------

On Error: [Event Procedure]
----------------------------------------------------------------------------------
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' MsgBox DataErr

If Screen.ActiveControl.Name = "NoMouseWheel" Then
Response = acDataErrContinue
End If
End Sub
----------------------------------------------------------------------------------

ADD THIS CODE BEHIND YOUR FORM:
----------------------------------------------------------------------------------
Option Compare Database
Option Explicit

'This Enum is for clarifying the code
Private Enum wsTrigger
TheWheel = 1
NotTheWheel = 2
End Enum

Private mWheel As Boolean
Private ValidationTrigger As wsTrigger

Private Function WheelSpin() As Integer
'used in NoMouseWheel text box on form
WheelSpin = mWheel
Select Case ValidationTrigger
Case NotTheWheel
mWheel = False
End Select
End Function
----------------------------------------------------------------------------------


| Is there any way to programmatically disable the wheel scroll function for
| end-users when they are using an Access application
|
| Thanks
 
Hi dont know if this helps anyone but I think Ive found a new twist to this
one. I didnt want to use a dll in a comercial app and the MS basaddin was
resource hungry I have this aversion to constant running code, so I came up
with a trap so that once a record had been created the form locked down into
that one rec so mouse wheel was irrelevant - not as elegent as yours but
useful in its own way but I use the mousewheel for a couple of things like
where I do have one to many as opp to one to one. My app is also driven
around one main form calling in various subforms with a dropbox in the
mainform which allows users to call up new records in the subform which left
me no way at the form level to have a changed record event. I should really
stick it in a class but as usual in a rush... Anyway appears to work as is
and I am sure someone can class it up tidily.

On the (sub)form's module you want to lockdown

Private Sub Form_Open(Cancel As Integer)
call recchange
end sub

Sub RecChange()
On Error Resume Next
DoEvents
Me.Form.Refresh
Me.AllowAdditions = IsNull(Me.DistribID.Value)
If Err = 2427 Then Me.AllowAdditions = True
Me.Form.Refresh
Me.YearSigned.SetFocus
End Sub

Private Sub Form_AfterInsert()
Me.AllowAdditions = False
End Sub

and against the afterevent on my combo box that changes the record in the
subform

Dim strMod As String
Dim lngSLine As Long, lngSCol As Long
Dim lngELine As Long, lngECol As Long
DoEvents
If Me.Subform1.Form.Module.Find("Recchange", lngSLine, lngSCol,
lngELine, lngECol) Then
Me.Subform1.Form.RecChange
End If

Hope that makes sense. It also gave me a changedata event in the subform
which I was missing before.
The text search was the only way I could find of calling the subforms
modulecode as eval failed.

rgds
stephen


DebbieG said:
This works for me in Access XP. This works in Single Form, not Continuous
Forms.

HTH,
Debbie


Add a Text Box on your form:

Name = NoMouseWheel
Default Value = " "
Validation Rule = WheelSpin() = False
Validation Text = You can't change records using your mouse wheel. (this
can
be left out if you don't want a message)
Visible = Yes
Enabled = Yes
Locked = No
Tab Stop = No
Back style = Transparent
Back Color = -2147483633 (or whatever color your form is)
Special Effect = Flat
Border style = Transparent

FORM EVENTS:

On Mouse Wheel: [Event Procedure]
----------------------------------------------------------------------------------
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
On Error GoTo GotError
mWheel = True
ValidationTrigger = TheWheel
Me.NoMouseWheel.SetFocus
Me.NoMouseWheel.Text = " "

ExitSub:
ValidationTrigger = NotTheWheel
Exit Sub

GotError:
MsgBox Err.Number & vbCrLf & Err.Description
Resume ExitSub
End Sub
----------------------------------------------------------------------------------

On Error: [Event Procedure]
----------------------------------------------------------------------------------
Private Sub Form_Error(DataErr As Integer, Response As Integer)
' MsgBox DataErr

If Screen.ActiveControl.Name = "NoMouseWheel" Then
Response = acDataErrContinue
End If
End Sub
----------------------------------------------------------------------------------

ADD THIS CODE BEHIND YOUR FORM:
----------------------------------------------------------------------------------
Option Compare Database
Option Explicit

'This Enum is for clarifying the code
Private Enum wsTrigger
TheWheel = 1
NotTheWheel = 2
End Enum

Private mWheel As Boolean
Private ValidationTrigger As wsTrigger

Private Function WheelSpin() As Integer
'used in NoMouseWheel text box on form
WheelSpin = mWheel
Select Case ValidationTrigger
Case NotTheWheel
mWheel = False
End Select
End Function
----------------------------------------------------------------------------------


| Is there any way to programmatically disable the wheel scroll function
for
| end-users when they are using an Access application
|
| Thanks
 
Back
Top