On Mouse Down - Many controls

J

Jay

This question might belong in the "Forms Coding", "Macros", and/or "Module
Coding" groups, but I wasn't sure which, so I thought I would try posting it
in this group.

I am using Access 2007. I have a form on which I would like some of the
fields to perform a certain action on a right mouse click. I know I can go
into VBA and for each of those controls, create a ControlName_MouseDown
subroutine. I can then do:

If Button = acRightButton
'my stuff
End If

or

If Button = acRightButton
DoMyStuff
End If

and put my code in a single subroutine called DoMyStuff.

What I would really like to do is just have one VBA subroutine that multiple
fields could call directly on the MouseDown event. That way I could code a
For Each loop that goes through all the fields at runtime, decides which ones
should react to a right click, and then "tells" those controls to run my one
subroutine on MouseDown. That one subroutine would need to be able to detect
which mouse button was clicked, no matter which field called it.

Is there any way to do this? I can't use a macro and assign that macro name
to each control's OnMouseDown property because macros can't determine which
mouse button was clicked. Or maybe they can, but I haven't found how yet, so
any help on that would be appreciated also.

Jay
P.S.: Sorry if this appears twice, I got an error on my first attempt to
post it.
 
Top