Results 1 to 11 of 11
  1. #1
    Join Date
    Mar 2006
    Posts
    33
    Provided Answers: 1

    Angry Unanswered: Disable The Mousewheel

    Hi, Can anyone help me to somehow restrict the mouswheel from cycling through the records
    i dont want a user to see the other records in the subform- its in form view and not in datasheet view- and i want only the latest record to be displayed

  2. #2
    Join Date
    Nov 2003
    Posts
    1,487
    This question (and answer) is not only all over this forum but is also all over the internet.

    Please....try the search engine in this forum...and if for some reason it doesn't work, use Google.

    .
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  3. #3
    Join Date
    Mar 2006
    Posts
    33
    Provided Answers: 1
    that was......
    anyways ive tried and will continue......the point is the solution availabe so far is one that will disable the mousewheel through the windows environment i require only for a particular window....and ofcourse idea is to restrict mov to another record when the mose is scrolled

  4. #4
    Join Date
    Nov 2003
    Posts
    1,487
    The 'point' is well understood and it would be incredibly ludicrous to assume that we would want to disable the fun loving mose, moose or mouse wheel for anything other than a specific Window within the MS-Access environment. Heaven forbid should we loose this voluptuous creature feature from our Web Browsers or Word Processing applications (at any given time).

    In any case…the trick here would be to hook the mouse wheel and ignore it when desired then Unhook it when we want to use it again. Now, this can all be done through code but even Microsoft themselves suggest that it is best accomplished using a ActiveX DLL. Yes, Microsoft also goes into some detail about the ways and means to disable the Mouse Wheel.

    In the far chance that you do not contain a copy of VB6.0 so as to create a ActiveX DLL, I took the liberty to do so for you. It is attached to this post. All you need to do is reference the DLL and use it. He is how you can go about it:

    You will need to Create a Reference to the ActiveX DLL which is named simply, MouseWheel.dll. To do this merely Start Microsoft Access, and then open your database project.

    Open the Form or SubForm you would like to prevent the Mouse Wheel to operate in. Be sure to open it in Design View.

    Next, in the View menu, click Code to display the module of the Form in the Visual Basic Editor (VBE).

    In the Tools menu, click References. To select the reference, locate (scroll down) and click (select) the check box next to reference MouseWheel. If this reference is not listed, click the Browse button located within the Reference dialog window, click MouseWheel.dll in the folder where you saved and then click Open. It’s best to place this ActiveX DLL into the \Windows\System32 folder before you reference it. Click OK to close the References dialog box.


    Add the following code to the code module of your Form (SubForm):

    Code:
    Option Compare Database
    Option Explicit
     
    Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel
     
    Private Sub Form_Load()
        Set clsMouseWheel = New MouseWheel.CMouseWheel
        Set clsMouseWheel.Form = Me
        clsMouseWheel.SubClassHookForm
    End Sub
     
    Private Sub Form_Close()
       ' MAKE SURE YOU HAVE THIS IN THE FORM’S CLOSE EVENT!!!
      clsMouseWheel.SubClassUnHookForm
       Set clsMouseWheel.Form = Nothing
       Set clsMouseWheel = Nothing
    End Sub
     
    Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
        MsgBox "Whoops…Sorry, you cannot use the mouse wheel to scroll records in this Form.", VbInformation, “Mouse Wheel Not Available”
        Cancel = True
    End Sub
    

    Now, in the File menu, click Close and return to Microsoft Access. Save and close your Form. Give it a shot and see if that mouse squeaks. If it does, shoot it again.


    .
    Attached Files Attached Files
    Environment:
    Self Taught In ALL Environments.....And It Shows!


  5. #5
    Join Date
    May 2005
    Location
    Melbourne, Australia
    Posts
    34

    Eloquent and Elegant

    Thanks for the entertaining answer to this question, CyberLynx.

    I'm sure this code will come in handy one day.

    I just tested it and it works great.

  6. #6
    Join Date
    Sep 2007
    Posts
    148
    I have been searching for help to stop the mousewheel in my access database for quit some time now. Finally, this one seems to work. Thank you very much.

  7. #7
    Join Date
    Sep 2007
    Posts
    148
    hello CyberLynx,

    I have used your coding for all my forms and they are working great. However, my main form has many subforms and they are all inside a big tab control. When I put the coding inside those forms, my mouse cannot get inside the form. Any idea. That is I cannot get inside the subform to do anything.

    Thanks

  8. #8
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Besides the code CyberLynx supplied, you may also want to look at the mousewheel code in the code bank (there are 2 different ways, one is the way Cyberlynx showed you.) Perhaps you can get some answers from looking at those. I also had problems with disabling the mousewheel for subforms and I'm looking for a solution in the code bank examples.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  9. #9
    Join Date
    Sep 2007
    Posts
    148
    I found this suggestion/coding from utteraccess

    Here is the idea. I use this idea for my subform with a little modification. It is one big step closer to what I want. Will keep looking and trying.


    ************************************************** ************************************************** **
    thanks, the easiest way I found was to add this code to the form: (comes from A better mouse trap)


    Code:
    --------------------------------------------------------------------------------


    Private Sub Form_BeforeUpdate(Cancel As Integer)
    On Error GoTo Err_Form_BeforeUpdate


    If Me.tbProperSave.Value = "No" Then
    DoCmd.CancelEvent
    Exit Sub
    End If

    Exit_Form_BeforeUpdate:
    Exit Sub

    Err_Form_BeforeUpdate:
    If Err = 3020 Then 'Update or CancelUpdate without AddNew or Edit
    Exit Sub
    Else
    MsgBox Err.Number, Err.Description
    Resume Exit_Form_BeforeUpdate
    End If

    End Sub

    Private Sub Form_Current()
    On Error GoTo Err_Form_Current

    Me.tbProperSave.Value = "No"

    Exit_Form_Current:
    Exit Sub

    Err_Form_Current:
    MsgBox Err.Number, Err.Description
    Resume Exit_Form_Current

    End Sub

    --------------------------------------------------------------------------------


    I also used this code in my button to close the form:
    Code:
    --------------------------------------------------------------------------------


    Me.tbProperSave.Value = "Yes"
    DoCmd.RunCommand acCmdSaveRecord
    DoCmd.Close

    --------------------------------------------------------------------------------

    It works like a charm and is very easy to implement.

  10. #10
    Join Date
    Nov 2007
    Location
    Adelaide, South Australia
    Posts
    4,049
    ?? What has this to do with disabling a mouse wheel ??
    Owner and Manager of
    CypherBYTE, Microsoft Access Development Specialists.
    Microsoft Access MCP.
    And all around nice guy!


    "Heck it's something understood by accountants ... so it can't be 'that' difficult..." -- Healdem
    "...teach a man to code and he'll be frustrated for life! " -- georgev

  11. #11
    Join Date
    Sep 2007
    Posts
    148
    No, nothing. I just could not find a way to disable the mouse wheel inside a subform. this method which I find out now that I do need to set tbpropersave to "NO" in every control "after update" event to make it work properly.

    I want to prevent user to roll to another record accidently while putting data in one record.

    I don't know what to do and still searching for a better method.

Posting Permissions

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