I need to disable the mouse scroll wheel to prevent a user from scrolling through records. I have been able to disable the PgUp and PgDn keys but have had no luck with the mouse wheel.
I have been trying to do the same this with my database as well and I have come up with something that works and is less complicated than the one Microsoft Suggests although it is a little crude it does the trick. Let me know what you think of it you can add any improvements you want I am open to any suggestions.
This is what I did
Assuming you already have a form
Make sure your Navigation buttons are turned off you won't need them.
Instead replace the navigation buttons with your own command buttons.
Next Button (cmdNext)
Previous Button (cmdPrevious)
First Button (cmdFirst)
Last Button (cmdLast)
New Button (cmdNew)
after you have created these buttons you will create three additional textboxes
first textbox will be called
txtCurrent_Record
Second textbox will be called
tdtRecord
Third textbox will be call
txtRecord_Value
Now comes the code behind the form
on the onload event of the form you will enter
Me.txtRecord_Count = " Record " & Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount
Me.txtRecord = Me.CurrentRecord
Me.txtRecord_Value = "1"
On the oncurrent event of the form you will enter
Me.txtRecord_Count = " Record " & Me.CurrentRecord & " of " & Me.RecordsetClone.RecordCount
If Me.txtRecord_Value = "0" Then
Me.txtRecord_Value = "0"
Else
Me.txtRecord_Value = "1"
End If
If Me.txtRecord_Value = "1" And Me.CurrentRecord < Me.txtRecord Then
DoCmd.GoToRecord , , acNext
ElseIf Me.txtRecord_Value = "1" And Me.CurrentRecord > Me.txtRecord Then
DoCmd.GoToRecord , , acPrevious
End If
On the onclick event of the cmdNew Button you will enter
Me.txtRecord_Value = "0"
Me.AllowAdditions = True
DoCmd.GoToRecord , , acNewRec
Me.txtRecord = Me.CurrentRecord
Me.txtRecord_Value = "1"
on the onclick event of the cmdFirst Button you will enter
Me.txtRecord_Value = "0"
Me.AllowAdditions = True
DoCmd.GoToRecord , , acFirst
Me.txtRecord = Me.CurrentRecord
Me.txtRecord_Value = "1"
on the onclick event of the cmdLast Button you will enter
Me.txtRecord_Value = "0"
Me.AllowAdditions = True
DoCmd.GoToRecord , , acLast
Me.txtRecord = Me.CurrentRecord
Me.txtRecord_Value = "1"
on the onclick event of the cmdNext Button you will enter
If Me.NewRecord Then
Me.Recordset.MoveLast
Else
Me.txtRecord_Value = "0"
DoCmd.GoToRecord , , acNext
Me.txtRecord = Me.CurrentRecord
Me.txtRecord_Value = "1"
End If
on the onclick event of the cmdPrevious Button you will enter
On Error GoTo ErrPrevious:
Me.txtRecord_Value = "0"
DoCmd.GoToRecord , , acPrevious
Me.txtRecord = Me.CurrentRecord
Me.txtRecord_Value = "1"
Exit Sub:
ErrPrevious:
MsgBox ("you are at the first record"
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.