Determine which button

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
 
G

Graham Mandeno

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.
 
S

Sandra Daigle

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
 
T

Tokash

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

.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top