PDA

View Full Version : Solved: Return which control triggered an AfterUpdate event



klinsman08
07-31-2012, 02:07 PM
I have a UserForm which has many TextBoxes. Each TextBox has an AfterUpdate event, which calls a function, and one of the inputs to the function is the original TextBox which triggered the AfterUpdate event. Is there a way to automatically detect which TextBox triggered the event? Right now I manually set an object variable to the TextBox inside AfterUpdate and then pass it to the function, but that gets pretty clunky.

An example of my code how it is right now:

Private Sub delta__1_AfterUpdate()
Dim variable, grade As String
Dim obj As Object
Dim check As Integer
'' Definitions [These change based on what the text box is for]
Set obj = delta__1
variable = "Delta "
'' Check if within bounds:
check = verify_params.MsgWhenInputRejected(obj, variable, 0)

End Sub

Bob Phillips
07-31-2012, 04:08 PM
Use the ActiveControl object, you can test that.

klinsman08
08-01-2012, 07:42 AM
Works perfect! I tried that earlier with no luck, but after a little digging figured out that since my textboxes are in a frame, I have to use ActiveControl.ActiveControl. Thanks!

Bob Phillips
08-01-2012, 11:23 AM
LOL! That looks silly doesn't it?