There are tons of information on the internet on how to stop the scrolling through records. Most of them require an external dll or ActiveX so I had to find something else (due to the way my application is distributed).
I found a way to do this with a few lines of code in VBA, it’s not the most elegant but it works very well in my application. So here it is, in case somebody else can use it.
Situation:
In my application I various forms that display only one record at a time (Single Form view). None of these forms is designed to allow navigation through records, I always open just one record (from a list).
The same form used for editing a record is used for adding a record as well. I never add two records in the same action.
The form has the Cycle property set to Current Record and the AllowAdditions property is set to true only when the form is used for adding a new record (Me.AllowAdditions = Me.DataEntry in the Form_Load event procedure).
The problem:
When I’m in the DataEntry mode (for adding a new record) using the scroll wheel determines unwanted navigation to the next new record.
Solution:
I found a way to do this with a few lines of code in VBA, it’s not the most elegant but it works very well in my application. So here it is, in case somebody else can use it.
Situation:
In my application I various forms that display only one record at a time (Single Form view). None of these forms is designed to allow navigation through records, I always open just one record (from a list).
The same form used for editing a record is used for adding a record as well. I never add two records in the same action.
The form has the Cycle property set to Current Record and the AllowAdditions property is set to true only when the form is used for adding a new record (Me.AllowAdditions = Me.DataEntry in the Form_Load event procedure).
The problem:
When I’m in the DataEntry mode (for adding a new record) using the scroll wheel determines unwanted navigation to the next new record.
Solution:
Code:
'in the module declarations add:
Dim fromwheel As Boolean
'in the Form_Current event procedure add
Private Sub Form_Current()
If Me.DataEntry And fromwheel Then
'this is an unwanted scrolling, go back to the previous record (which is the first one as well)
fromwheel = False 'clear the flag
DoCmd.GoToRecord , , acFirst
End If
End Sub
'in the on Form_MouseWheel event procedure add
Private Sub Form_MouseWheel(ByVal Page As Boolean, ByVal Count As Long)
If Count > 0 And Me.AllowAdditions Then fromwheel = True
'signals to the following Form_Current event that this is an unwanted scrolling
End Sub