Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 2 / March 2007

Tip: Looking for answers? Try searching our database.

Problem with ActiveX Mousewheel

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Max Moor - 31 Mar 2007 01:39 GMT
Hi All,
       Sorry for posting in the general group.  I posted this in the ActiveX
group, but it looks like that group is all but extict.  I thought I'd try
my luck.

       I've used the MouseWheel control in the past without problem, but now
I have one.  In trying to understand it, I came up with a question as well.  
Here's both...

The Problem:

       I use the control to make the mousewheel act on a listbox, called
lstGroup, that is on the form.  The code I include in the form's module is
at the bottom of the post.  Whenever I close the form, I get the error:

              Runtime error '91':
              Object variable or With block variable not set

       If I select Debug, the debugger starts on the first line of the
Form_Deactivate code.

       This is a form I've copied from a working app, with the MouseWheel
code identical.  My concern is that I'm doing something horribly wrong, and
have just gotten lucky with my working app, which could explode at any
moment.

       Can anyone tell me what I might be doing wrong?

The Question:

       I looked up the use of "WithEvents," and the Visual Basic help says it
is only valid in class modules.  Is a form module considered a class
module, or is that keyword not actually doing anything where I'm using it?

As always, thanks to the MVPs!

- Max

'''''''' Code At The Top Of The Form's Module ''''''''

Private WithEvents clsMouseWheel As MouseWheel.CMouseWheel

Private Sub Form_Activate()
   Set clsMouseWheel = New MouseWheel.CMouseWheel
   Set clsMouseWheel.Form = Me
   clsMouseWheel.SubClassHookForm
End Sub

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

Private Sub clsMouseWheel_MouseWheel(Cancel As Integer)
   
   Dim ctlCurrent As Control

   Set ctlCurrent = Screen.ActiveControl
   If (ctlCurrent.Name <> "lstGroup") Then
   
       Me!lstGroup.SetFocus
       Cancel = True
   
   End If
End Sub
Douglas J. Steele - 31 Mar 2007 01:49 GMT
Why not just grab what Stephen Lebans has at
http://www.lebans.com/mousewheelonoff.htm?

Signature

Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)

> Hi All,
>    Sorry for posting in the general group.  I posted this in the ActiveX
[quoted text clipped - 64 lines]
>    End If
> End Sub
Max Moor - 31 Mar 2007 06:26 GMT
> http://www.lebans.com/mousewheelonoff.htm?

Hi Douglas,

       I looked at Stephen's code some time ago.  It looks a much simpler
on/off switch, but I couldn't figure out how to use it to tie the mousewheel
to a specific control.

       I don't want the mousewheel off, just to scroll a specific listbox on a
form, but never the main form itself.  If the form scrolls, the controls go
blank.  I noticed that even happens to the subform in Stephen's example
database.

- Max
Max Moor - 31 Mar 2007 06:33 GMT
> Why not just grab what Stephen Lebans has at
> http://www.lebans.com/mousewheelonoff.htm?

Hi Again,

       Just after I hit send, it occurred to me that I wasn't quite clear.  I
don't need the MouseWheel or MouseHook code to do the scrolling of the
listbox.  I actually use the MouseWheel just to let me capture the Mousewheel
event when it occurs.  I use code in the event to set the focus to the
listbox.  That way any scroll of the Mousewheel gets focused on that listbox,
or other control.

       I should have said that I didn't see how Stephen's code allowed my to
capture the Mousewheel event.  (I'd love a better method than the MouseWheel
ActiveX control.)

- Max
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.