On_Mouse_Wheel: Call DoWheelMouse(Me, Count)
Const sc_ACCESSFORMVIEW as long = 1
'-----------------------------------------------
'Purpose:   Make the MouseWheel scroll in Form View in Access 2007 and later.
'           This code lets Access 2007 behave like older versions.
'Return:    1 if moved forward a record, -1 if moved back a record, 0 if not moved.
'Author:    Allen Browne, February 2007.
'Usage:     In the MouseWheel event procedure of the form:
'               Call DoMouseWheel(Me, Count)
'
Public Function DoWheelMouse(ByVal Frm As Form, _
                             ByVal lngCount As Long) As Integer
    On Error GoTo Err_Handler
        ' Run this only in Access 2007 and later,
        ' and only in Form view.
        If (Val(SysCmd(acSysCmdAccessVer)) >= 12#) _
       And (Frm.CurrentView = sc_ACCESSFORMVIEW) _
       And (lngCount <> 0&) Then
            ' Save any edits
            ' before moving record.
            If Frm.Dirty Then
                Frm.Dirty = False
            End If
            ' Move back a record if Count is negative,
            ' otherwise forward.
            RunCommand IIf(lngCount < 0&, _
                           acCmdRecordsGoToPrevious, _
                           acCmdRecordsGoToNext)
            DoWheelMouse = Sgn(lngCount)
        End If
Exit_Handler:
    Exit Function
Err_Handler:
    Select Case Err.Number
        Case 2046&
            'Can't move before first, after last, etc.
            Beep
        Case 3314&, 2101&, 2115&
            'Can't save the current record.
            MsgBox "Cannot scroll to another record, " & _
                   "as this one can't be saved.", _
                   VbMsgBoxStyle.vbOKOnly, _
                   "Cannot scroll"
        Case Else
            MsgBox "Error " & Err.Number & _
                   ": " & Err.Description, _
                   VbMsgBoxStyle.vbOKOnly, _
                   "Cannot scroll"
    End Select
    Resume Exit_Handler
End Function