Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2002
    Location
    Island of Dots
    Posts
    316

    Unanswered: Mousewheel in subforms

    I have a data entry form (frmDataEntry), which contains a sub-form (fsubOwnerHistory). I want to disable the mouse wheel on both the parent and child forms. I have successfully implemented the dll solution as descriped on Microsofts knowledge base to disable the mousewheel. This works perfectly in cases where you are opening and closing individual forms. However, I am having problems disabling the mousewheel in both parent and child forms.

    Here is the code I'm using in the parent form:

    Option Compare Database
    Private WithEvents clsMouseWheel As MouseWheel.cMouseWheel

    Private Sub Form_Open(Cancel As Integer)
    Set clsMouseWheel = New MouseWheel.cMouseWheel
    Set clsMouseWheel.Form = Me
    clsMouseWheel.SubClassHookForm
    DoCmd.RunCommand acCmdRecordsGoToFirst
    End Sub

    Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
    'MsgBox "You cannot use the mouse wheel to scroll records."
    Cancel = True
    End Sub

    Private Sub fsubOwnerHistory_Enter()
    clsMouseWheel.SubClassUnHookForm
    Set clsMouseWheel.Form = Nothing
    Set clsMouseWheel = Nothing
    End Sub

    Private Sub fsubOwnerHistory_Exit(Cancel As Integer)
    Set clsMouseWheel = New MouseWheel.cMouseWheel
    Set clsMouseWheel.Form = Me
    clsMouseWheel.SubClassHookForm
    End Sub


    And here is the code for my child form (fsubOwnerHistory):

    Option Compare Database

    Private WithEvents clsMouseWheel As MouseWheel.cMouseWheel

    Private Sub Form_Open(Cancel As Integer)
    Set clsMouseWheel = New MouseWheel.cMouseWheel
    Set clsMouseWheel.Form = Me
    clsMouseWheel.SubClassHookForm
    End Sub

    Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
    'MsgBox "You cannot use the mouse wheel to scroll records."
    Cancel = True
    End Sub


    The above sucessfully disables the mousewheel in frmDataEntry, but it does not disable the mousewheel in fsubOwnerHistory. In fact, it stops you actually entering any data into fsubOwnerHistory.

    As can be seen in the code, I UnHook frmDataEntry when focus changes from frmDataEntry to fsubOwnerHistory, and I Hook when focus changes from fsubOwnerHistory to frmDataEntry. I have tried different points at which to Hook and UnHook within fsubOwnerHistory, but everything fails.

    It should be noted that frmDataEntry is a complex form, so I load it only once, and when other screens in the database are accessed it is hidden rather than closed.

  2. #2
    Join Date
    Feb 2004
    Posts
    5

    Having the same problem

    I have been running into the same problem with my subforms. If you come up with a solution please let me know. I will do the same if I can figure it out. I have the DLL file I am trying now but I have thought about trying to do it all in Access to see if that might help.

    Thanks
    Kracht1978

  3. #3
    Join Date
    Jul 2002
    Location
    Island of Dots
    Posts
    316
    Unfortuantely, I never found a solution. I had to radically change the way I was designing forms to get round the problem. If you set the forms AllowAdditions property to 'No' you can disable the mousewheel that way, since you can only view the current record. You need to set your forms record source to one or one set of records though, otherwise the forms objects will not be displayed if a record isn't associated with the form.

Posting Permissions

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