Determine which button

  • Thread starter Thread starter Tokash
  • Start date Start date
T

Tokash

I have several buttons on a form all pointing to the same
subroutine. Is there a way within the subroutine to
determine which button called it?

Thanks for any help,
Tok
 
Hi Tok

Me.ActiveControl.Name will give you the name of the button that was clicked.
Or, you could give each one a Tag value and check Me.ActiveControl.Tag.

If this common function is not in the form's class module, then use
Screen.ActiveControl, or Forms![MyForm].ActiveControl.
 
Try using me.Activecontrol. For example, the following will display the name
of the clicked button

Private Function ClickStuff()
MsgBox "Button Clicked was " & Me.ActiveControl.Name
End Function
 
Thank you Sandra and Graham. That did the trick!
-----Original Message-----
Try using me.Activecontrol. For example, the following will display the name
of the clicked button

Private Function ClickStuff()
MsgBox "Button Clicked was " & Me.ActiveControl.Name
End Function

--
Sandra Daigle
[Microsoft Access MVP]
For the benefit of others please post all replies to this newsgroup.

I have several buttons on a form all pointing to the same
subroutine. Is there a way within the subroutine to
determine which button called it?

Thanks for any help,
Tok

.
 
Back
Top