|
|
|
|
|
|
Access
|
Stop mouse wheel on form
|
|
Ease of Use
|
Intermediate
|
Version tested with
|
2003
|
Submitted by:
|
Trevor
|
Description:
|
will display an error message if the user tries to scroll though records
|
Discussion:
|
want to stop user's of your DB from using the scroll wheel to scroll through records, or disable the mouse so it will not allow the user to scroll in a subform, to the next or previous record, this code will display an error message to the user that they are not allowed to scroll in 'this form.
|
Code:
|
instructions for use
|
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_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
Msgbox "you can't scroll on this form, please stop scrolling", _
vbOKOnly + vbwarning, "No mouse scroll"
Exit Sub
Sub_Err:
Resume Sub_Exit
End Sub
|
How to use:
|
- Place an unbound textbox on your form with the name of 'unboundtextbox', color o the textbox is the same color as your form. leave the enabled proporty set to 'yes and the locked proporty set to = no,
- Hint: make the textbox as narrow as possable and it will be invisible to your end user
- and place the above code in the code section of your form.
- set the form proporties, on Event:
- On Error = [Event Procedure]
- Mouse Wheel = [Evdnt Procedure]
|
Test the code:
|
- place the code in a blank form and set the above events (mous wheel & On error) both on for proporties and the click view form and try to scroll, you'll get the error message.
|
Sample File:
|
No Attachment
|
Approved by Jacob Hilderbrand
|
This entry has been viewed 148 times.
|
|