Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Setting event procedures to call functions in vba

Status
Not open for further replies.

jender624

Programmer
Jul 1, 2003
50
US
I'm trying to loop through all the controls on my forms, and set the mousemove event to call a function through code. I don't know if/how I can set the mousemove event to call a function, however. Is there a way to do this?

Thanks,

jender624
 
It should be fairly straightforward:
Code:
Private Sub <ControlName>_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
   Call <ProcName> (<arguement list>)
End Sub



Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
Thanks for replying! Maybe I'm not being clear. I'm trying to do something like this:

For Each ctl in Me
ctl."MouseMoveEvent" = "FunctionName"
next ctl

I'm just not sure of the syntax to do something like this. Is it possible?

Thanks,

jender624
 
No, that's not possible because during runtime, when an event is triggered, control is passed directly to a routine (if it exists) called <ControlName>_<EventName>. That is the intrinsic architecture of the event handler.

Good Luck
--------------
As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
 
I think I found a way to do this. As opposed to directly trying to set the event procedure to call a function, I'm setting it to call a macro which in turn calls the function I need. This seems to work. Thanks again.

jender624
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top