Results 1 to 2 of 2
  1. #1
    2 Star Lounger
    Join Date
    Apr 2009
    Posts
    114
    Thanks
    18
    Thanked 0 Times in 0 Posts
    Hello
    I have a user that is getting the following error after creating the macro to turn on the mouse wheel in Access 2007. Any ideas? Thanks in advance for any assistance you can provide

    The error Compile Error: Expected: end of statement

    And the On is highlighted



    Option Compare Database



    Public Function DoMouseWheel (frm As Form, lngCount As Long) As Integer On Error GoTo Err_Handler



    'Purpose: Make the MouseWheel scroll in Form View in Access 2007.

    ' 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: Deana Palmer, September 2007.

    'Usage: In the MouseWheel event procedure of the form:

    Call DoMouseWheel(Me, Count)

    Dim strMsg As String

    'Run this only in Access 2007 and later, and only in Form view.

    If (Val(SysCmd(acSysCmdAccessVer)) >= 12#) And (frm.CurrentVeiw = 1) And (lngCount <> 0&) Then

    'Save any edits before moving record.

    RunCommand acCmdSaveRecord

    'Move back a record if Count is negativ, otherwise forward.

    RunCommand IIf(lngCount < 0&, acCmdRecordsGoToPrevious, acCmdRecordsGoToNext)

    DoMouseWheel = 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.

    strMsg = "Cannot scroll to another record, as this one can't be saved."

    Case Else

    strMsg = "Error " & Err.Number & ": " & Err.HelpDescription

    MsgBox strMsg, vbInformation, "Cannot scroll"

    End Select

    Resume Exit_Handler

    End Function

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    The line

    Public Function DoMouseWheel (frm As Form, lngCount As Long) As Integer On Error GoTo Err_Handler

    should be two lines:

    Public Function DoMouseWheel (frm As Form, lngCount As Long) As Integer
    On Error GoTo Err_Handler

    A bit further down, CurrentVeiw should be CurrentView

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •