Hi,
I have 5 buttons that i only mapped to 1 Procedure. My issue is I need to know the Button name or caption when it is click.
Do anyone know how to do that?
Much appreciated.
Thank you
Lex
Hi,
I have 5 buttons that i only mapped to 1 Procedure. My issue is I need to know the Button name or caption when it is click.
Do anyone know how to do that?
Much appreciated.
Thank you
Lex
Last edited by lexusap; 09-27-2016 at 12:30 AM.
Hi,
The simplest method is to use Me.ActiveControl.Caption in your code, as long as the TakeFocusOnClick property of the buttons is set to True- which is the default.
Don
Please remember to mark your thread 'Solved' when appropriate.
The easiest option is to share your code so we can take a look and give you a to the point answer.
Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.
Maybe:
use the code
Private Sub UserForm_Initialize()
'
CommandButton1.Tag = "CommandButton1"
CommandButton2.Tag = "CommandButton2"
CommandButton3.Tag = "CommandButton3"
CommandButton4.Tag = "CommandButton4"
CommandButton5.Tag = "CommandButton5"
'
End Sub
Private Sub CommandButton1_Click()
'
MsgBox "Caller = " & CommandButton1.Tag
'
End Sub
Private Sub CommandButton2_Click()
'
MsgBox "Caller = " & CommandButton2.Tag
'
End Sub
Private Sub CommandButton3_Click()
'
MsgBox "Caller = " & CommandButton3.Tag
'
End Sub
Private Sub CommandButton4_Click()
'
MsgBox "Caller = " & CommandButton4.Tag
'
End Sub
Private Sub CommandButton5_Click()
'
MsgBox "Caller = " & CommandButton5.Tag
'
End Sub
Hi,
Thanks for your help, however i still could not figure out what how to fix this.
So in plain language, when any of the 4 buttons being clicked, it will call BN50_Send_no_Payment_file.![]()
Please Login or Register to view this content.
However depending on which one that has been clicked, i need to configure which file to get & who to send it.
I have attached sample for your consideration.
Thanks
Lex
You can change the called routine to
and the buttons' code to![]()
Please Login or Register to view this content.
However I see no real benefit in having all the buttons call one routine simply so that routine can call other routines for each button. Why do you not rather have each button call its related routine directly?![]()
Please Login or Register to view this content.
Thanks XLNitWit.
It works perfectly.
Regards
Albert
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks