Mouse Wheel in Forms

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

Guest

The mouse wheel (inbetween two buttons) on the mouse, when "wheeled" up and
down browse between records in a form. I wish to disallow this function, and
have the wheel do what it does on the web....to go up and down on the page
instead of scroll between records. What setting is needed to accomplish this
or just dissable the wheel alltogether?
 
The following works in single form, not in continuous forms.

Hope that helps,
Debbie

On your form, place an unbound TextBox with the following properties:

Name = UnboundTextBox
Default Value = " "
Validation Rule = WheelSpin() = False
Visible = Yes
Enabled = Yes
Locked = No
Tab Stop = No
Back Style = Transparent
Back Color = -2147483633 ' or whatever the color of the form is
Fore Color = -2147483633
Special Effect = Flat
Border Style = Transparent

On your Form Properties set:
On Mouse Wheel = [Event Procedure]
On Error = [Event Procedure]

Put the following code behind your form:

Private mWheel As Boolean
Private validationTrigger As wsTrigger

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

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 GotError
' allow MouseWheel if not editing or new record
If Me.Dirty Or Me.NewRecord Then - COMMENT THIS OUT IF WANTING TO
TOTALLY DISABLE
mWheel = True
validationTrigger = MyWheel
Me.UnboundTextBox.SetFocus
Me.UnboundTextBox.Text = " "
End If - COMMENT THIS
OUT IF WANTING TO TOTALLY DISABLE

ExitSub:
validationTrigger = NotTheWheel
Exit Sub

GotError:
' Value you entered doesn't meet the validation rule
If Err.Number = 2107 Then
Msgbox "You need to complete this record first." - COMMENT THIS
OUT IF WANTING TO TOTALLY DISABLE
Resume ExitSub
End If
' if any other error show error number, error description, and where the
error occurred
MsgBox Err.Number & vbCrLf & Err.Description & vbCrLf &
"Form_MouseWheel"
Resume ExitSub
End Sub

_______________________________________________________________

Private Sub Form_Error(DataErr As Integer, Response As Integer)
If Screen.ActiveControl.Name = "UnboundTextBox" Then
Response = acDataErrContinue
End If
End Sub



| The mouse wheel (inbetween two buttons) on the mouse, when "wheeled" up
and
| down browse between records in a form. I wish to disallow this function,
and
| have the wheel do what it does on the web....to go up and down on the page
| instead of scroll between records. What setting is needed to accomplish
this
| or just dissable the wheel alltogether?
 
Back
Top