ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Identify which button called the userform (https://www.excelbanter.com/excel-programming/424669-identify-button-called-userform.html)

RyanH[_2_]

Identify which button called the userform
 
I have 3 userforms (frmCC, frmEC, & frmPC) that have a particular button
Named "btnReveals". This button calls another userform named "frmReveals".
How can I identify which of the 3 userforms (frmCC, frmEC, & frmPC) have
called frmReveals?

For example, if frmCC calls frmReveals, I want to disable some controls on
frmReveals. If frmPC calls frmReveals, I want to disable a differenct set of
controls.

This is what I had in mind:

' frmReveals
Private Sub UserForm_Initialize()

' disable contols on Reveals userform depending on which button calls it
Select Case Application.Caller

Case Is = "Button 178" ' frmCC button
' disable non applicable reveal controls

Case Is = "Button 179" ' frmEC button
' disable non applicable reveal controls

Case Is = "Button 180" ' frmPC button
' disable non applicable reveal controls

End Sub

Thanks for your help in Advance!
--
Cheers,
Ryan

Dave Peterson

Identify which button called the userform
 
I'd create a public variable in a General module (not in any userform module)
and just set it before you load the frmReveals userform

Public WhichFrmName as string

....

In the 3 different forms button click event

whichfrmname = me.name
me.hide '???
frmreveals.show

then I could use whichfrmname in the _initialize event of frmreveals.


RyanH wrote:

I have 3 userforms (frmCC, frmEC, & frmPC) that have a particular button
Named "btnReveals". This button calls another userform named "frmReveals".
How can I identify which of the 3 userforms (frmCC, frmEC, & frmPC) have
called frmReveals?

For example, if frmCC calls frmReveals, I want to disable some controls on
frmReveals. If frmPC calls frmReveals, I want to disable a differenct set of
controls.

This is what I had in mind:

' frmReveals
Private Sub UserForm_Initialize()

' disable contols on Reveals userform depending on which button calls it
Select Case Application.Caller

Case Is = "Button 178" ' frmCC button
' disable non applicable reveal controls

Case Is = "Button 179" ' frmEC button
' disable non applicable reveal controls

Case Is = "Button 180" ' frmPC button
' disable non applicable reveal controls

End Sub

Thanks for your help in Advance!
--
Cheers,
Ryan


--

Dave Peterson


All times are GMT +1. The time now is 08:34 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com