I have a form with two dozen command buttons on it that will all perform a
similar routine. Each of the buttons click events will have its own
subroutine in the VBA code, and all the subroutines will call the same
function. To have that function perform logic specific to a given button, I'd
have to pass the name of the button to the function. I'd rather use a
variable, so that for each button click event subroutine that I create, all I
have to do is copy and paste the statement from another button's click event
without having to subsequently change the function argument to be the
button's name. (I know that sounds lazy, but two dozen is a lot, and anyway
I'm curious if it can be done.) An alternative would be to somehow use the
subroutine's name as the value (since the name of a command button's click
event contains the button's name). But I haven't found a way to do that
either.
Douglas J Steele - 05 Dec 2005 18:11 GMT
Screen.ActiveControl.Name

Signature
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
> I have a form with two dozen command buttons on it that will all perform a
> similar routine. Each of the buttons click events will have its own
[quoted text clipped - 9 lines]
> event contains the button's name). But I haven't found a way to do that
> either.
Marshall Barton - 05 Dec 2005 19:43 GMT
>I have a form with two dozen command buttons on it that will all perform a
>similar routine. Each of the buttons click events will have its own
[quoted text clipped - 9 lines]
>event contains the button's name). But I haven't found a way to do that
>either.
Me.ActiveControl.Name

Signature
Marsh
MVP [MS Access]
Marshall Barton - 05 Dec 2005 19:51 GMT
>>I have a form with two dozen command buttons on it that will all perform a
>>similar routine. Each of the buttons click events will have its own
[quoted text clipped - 11 lines]
>
>Me.ActiveControl.Name
Whoops, wasn't done typing.
Me.ActiveControl.Name is more specific than the
Screen.ActiveControl.Name
I really wanted to point out that you can set the OnClick
property to call your general function. Use =functionname()
instead of [Event Procedure] to save you from having a
separate function for each button that doesn't do anything
beyond calling the general procedure.

Signature
Marsh
MVP [MS Access]