Coding an Event to a Collection of Controls

ted.martin

Registered User.
Local time
Today, 08:55
Joined
Sep 24, 2004
Messages
743
I have a form with about 30 combo boxes and I am wondering whether putting them into a Collection will allow me to address each individual Combo's event property through the Collection rather having to code up each individual control?

For example

Code:
Private Sub Ctl1_1_KeyPress(KeyAscii As Integer)

If Len(Me.Controls(Screen.ActiveControl.Name).Value & "") = 0 Then Exit Sub
'======================================================

If KeyAscii = 77 Or KeyAscii = 109 Or KeyAscii = 100 Or KeyAscii = 68 Then
    
    Call acSendtoFile(Screen.ActiveControl.Name).Value
    
End If

End Sub

I would rather not have to code up each combo control individually; albeit copy and paste, 30 times.

Many thanks
 

Users who are viewing this thread

Back
Top Bottom