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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Simply applying code to a number of controls

Status
Not open for further replies.

ChrisN

Programmer
Jul 9, 2001
59
0
0
GB
Hi,

I have some 40 controls that I need to call the same piece of code (a public sub created in a module) when each control loses focus.

I was just wondering if there was a quick way to kind of do this once or do I just have to paste the sub's name into the LostFocus event of each of my 40 or so controls??

Any advice would be appreciated.

TIA,
Chris
 
The only other method I can think of is to place all 40 controls in a control array. But this will only work if the controls are of the same type. Thanks and Good Luck!

zemp
 
be careful with lost focus....to many people use this event for validation and it shouldn't be used for that.
 

If you do not want to create an array you will have to call the sub from each controls lost focus event, and perhaps if the code you are wanting to run is single control minded you could pass the control as one of the arguements. On the other hand you could create a class or your own activex control.

Good Luck

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top