Sorry about that...if you want to reuse the code, write the sub and then
call the specific sub from the onClick event of each button. This is
the only way to have the same code execute for multiple buttons, but it
reduces the amount of code.
sub mySubWhatever
(code)
end sub
sub cmdPrint_onClick()
call mySubWhatever
end sub
JHK wrote:
> Screen.ActiveControl.Caption does appear to be valid. (I'm using 2002)
>
> Any ideas?
>
> "Steve Schapel" wrote:
>
>
>>JHK,
>>
>>I think you could use this in your function:
>> Screen.ActiveControl.Caption
>>
>>--
>>Steve Schapel, Microsoft Access MVP
>>
>>
>>JHK wrote:
>>
>>>I'm trying to write code to create a Function that will, depending on the
>>>Command Button pressed on a form, take the name label (caption) of the button
>>>and assign the text to a string that I can then do something with.
>>>
>>>I know how to do this on an individual button basis as a private sub, but I
>>>have a need to do this with several buttons on a form and I don't want to
>>>have to copy the code and edit it for each button.
>>>
>>>Any assistance would be appreciated.
>>
|