If you have made a form where you don't whant your users to be able to scroll between records using the Mouse Wheel then this is for you. For those of you who have been here before. There are important changes in this faq.
This technique only works in "Form View" and I have only tried it on Access 2002/XP.
Step 1. On your form, place an unbound Text Box with the following properties: Visible = Yes Back Style = Transparent Back Color = -2147483633 Special Effect = Flat Border Style = Transparent Default Value = " " Validation Rule = WheelSpin()=False 'This setting is removed Validation Text = You can't change record using your mouse wheel! Enabled = Yes Locked = No Name = UnboundTextBox
Step 2. Then for your Form Properties set this: On Mouse Wheel = [Event Procedure] On Error = [Event Procedure]
Step 3. Place the following code behind your form:
'Global declarations should be here before the code
'This enum is for clarifying the code below. Private Enum wsTrigger MyWheel = 1 NotTheWheel = 2 End Enum
Private mWheel As Boolean Private ValidationTrigger As wsTrigger 'End of global declarations
Private Function WheelSpin() As Integer WheelSpin = mWheel Select Case ValidationTrigger Case NotTheWheel mWheel = False End Select End Function
Private Sub Form_Error(DataErr As Integer, Response As Integer) If Screen.ActiveControl.Name = "UnboundTextBox" Then Response = acDataErrContinue End If End Sub
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long) On Error GoTo Sub_Err mWheel = True ValidationTrigger = MyWheel Me.UnboundTextBox.SetFocus Me.UnboundTextBox.TEXT = " " Sub_Exit: ValidationTrigger = NotTheWheel Exit Sub Sub_Err: Resume Sub_Exit End Sub