I have a form with lets say 20 text boxes txtbox1 to txtbox20 and I would like to run the code under Form_Click or detail_Click instead of running the code for the control event.
Maybe I'm misunderstanding the question, but if you put your code in the Form or Detail Click event INSTEAD of the control(s) event, that would be the only way the code would be executed?
A sample of the code you want to run might be helpful.
Sorry for not being more specific.
What I want to do is following:
Everytime I click on one of the textboxes I want to run the same Sub. So in order not to put the same sub into all 20 txtbox1_Click to txtbox20_Click I thought I can give the Form click priority over the control click then I would save coding and it would look nicer. I would not have a module with 20 or more txtboxZ_Click Subs all calling the same code.
Hope this explains it a bit better.
Thx for answering my question
All events are tied to the objects that own that event. Every control is its own object with its own events (and properties and methods), so do to what you want to do would require sub-classing all of the controls, trap the event message, and based on the event message, either pass it back to the control for normal handling, or throw it away and raise the corresponding event for another object. Although doable, it would in no way be worth the effort.
A far better approach is to have the normal event handlers set up, and from within the event handler, call the common subroutine.
Sub Text1_Click
ExecGlobalClickRoutine
End Sub
Sub Text2_Click
ExecGlobalClickRoutine
End sub
and so forth. Then write your ExecGlobalClick routine.
Public Sub ExecGlobalClickRoutine
....
End Sub
Good Luck
-------------- As a circle of light increases so does the circumference of darkness around it. - Albert Einstein
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.