Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Set variable to command button property 1

Status
Not open for further replies.

dolfin13

Programmer
Jun 29, 2005
22
US
How would I refer to the caption of a button that was just clicked?

I would like to set a variable to the caption of cmd button in the click event of said button.

Thanks in advance, my mind is in the wrong place today.
 
Something like this ?
Me![command button name].Caption = "You've clicked me !"

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Or this:
Code:
Dim MyVar As String
MyVar = Me!MyButton.Caption
Ken S.
 
sort of...

but I have many buttons, and wondered if there is a way to refer to the that was just clicked.

Private Sub cmdButton_Click()

Dim strCaption As String

strCaption = Me.[button that was just pressed].Caption

is there a way to do this?

Thanks for the quick reply, I'm sorry if I'm being confusing.
 
OOps, my lack of english language knowledge ...
 
Try this:
Code:
Dim ctrl As Control
Dim strCaption As String
Set ctrl = Screen.ActiveControl
strCaption = ctrl.Caption
Ken S.
 
That's what I'm looking for!

Thanks a million!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top