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 / Modules / DAO / VBA / January 2006

Tip: Looking for answers? Try searching our database.

On Mouse Move

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Gary Robinson - 26 Jan 2006 11:49 GMT
Hi

When using the on mouse move event, is it possible ti return the name of the
object the mouse is over??

Many Thanks in advance

Gary
Brendan Reynolds - 26 Jan 2006 13:38 GMT
Each object has its own MouseMove event, so the object the mouse is over is
the object of which this is the MouseMove event, if you see what I mean?
There is no need to test, in the MouseMove event, what object the mouse is
over, because the very fact that this particular MouseMove event has been
fired tells you what object the mouse is over. For example ...

Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
   Me.Label3.Caption = "The mouse is over the 'Command0' object, or I would
not have been fired"
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
   Me.Label3.Caption = "The mouse is over the Detail object, or I would not
have been fired."
End Sub

Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single,
Y As Single)
   Me.Label3.Caption = "The mouse is over the form and not over any object
contained within the form, or I would not have been fired."
End Sub

Private Sub List1_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
   Me.Label3.Caption = "The mouse is over the 'List1' object, or I would
not have been fired"
End Sub

Signature

Brendan Reynolds
Access MVP

> Hi
>
[quoted text clipped - 4 lines]
>
> Gary
Gary Robinson - 26 Jan 2006 14:03 GMT
Hi

I understand that, i probably should have explained myself better!! I have a
form with many buttons on it, in the past i have written a function that
turns the text colour of the button a certain colour when the mouse is over
it, which has worked well but meant that i had to a reference to the
function in each 'mouse move event' with the name of the object (so the
function knows which button to change the colour of)  I was hoping there was
a way of having a generic function that could dtermine the name of the
button itself, so i would not have to type it out each time.

Thanks

Gary

> Each object has its own MouseMove event, so the object the mouse is over
> is the object of which this is the MouseMove event, if you see what I
[quoted text clipped - 34 lines]
>>
>> Gary
Brendan Reynolds - 26 Jan 2006 14:16 GMT
I see. I don't have a complete answer for you, but I guess you would need to
start by retrieving the current mouse pointer coordinates. There's code to
do that in the following post from the Google archives ...

http://groups.google.com/group/microsoft.public.access.modulesdaovba/browse_thre
ad/thread/269d1c2363d83d03


Signature

Brendan Reynolds
Access MVP

> Hi
>
[quoted text clipped - 49 lines]
>>>
>>> Gary
Tim Ferguson - 26 Jan 2006 19:12 GMT
"Gary Robinson" <garyr@mantra-int.com> wrote in news:#io0CFoIGHA.604
@TK2MSFTNGP14.phx.gbl:

> I was hoping there was
> a way of having a generic function that could dtermine the name of the
> button itself, so i would not have to type it out each time.

 Private Sub cmdOne_MouseEnter()
   Call MouseEnter("cmdOne")
 End Sub

 Private Sub cmdTwo_MouseEnter()
   Call MouseEnter("cmdTwo")
 End Sub

 ' and this is the common subroutine
 Private Sub MouseEnter(ControlName as String)
   Me.Controls(ControlName).TextColor = rgbBlue
   Me.lblStatusBar.Caption = "over the " & ControlName & " button"

 End Sub

This is about as modular as it gets with VBA I'm afraid.

Hope it helps

Tim F

 
Dirk Goldgar - 27 Jan 2006 04:06 GMT
> "Gary Robinson" <garyr@mantra-int.com> wrote in news:#io0CFoIGHA.604
> @TK2MSFTNGP14.phx.gbl:
[quoted text clipped - 19 lines]
>
> This is about as modular as it gets with VBA I'm afraid.

Well ...

If you change

   Private Sub MouseEnter(ControlName As String)

to

   Private Function MouseEnter(ControlName As String)

then you can set each individual control's OnMouseMove event *property*
to

   =MouseEnter("TheControlName")

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

Tim Ferguson - 27 Jan 2006 17:25 GMT
"Dirk Goldgar" <dg@NOdataSPAMgnostics.com> wrote in news:#ypXmbvIGHA.984
@tk2msftngp13.phx.gbl:

> then you can set each individual control's OnMouseMove event *property*
> to
>
>     =MouseEnter("TheControlName")

Of course!

Hang on: I always thought you couldn't put parameters into a Macro
properties. Must go experiment more...

All the best

Tim F
Dirk Goldgar - 27 Jan 2006 17:49 GMT
> Hang on: I always thought you couldn't put parameters into a Macro
> properties. Must go experiment more...

Not sure what you mean by "Macro properties".  I'm talking about the
event property that shows up on the Event tab of the control's property
sheet.  And what you'd be doing wouldn't be calling a macro, it would be
evaluating a function expression.  That has always worked for me,
parameters and all.

Signature

Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)

 
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.