Hello,
Leith Ross showed me the other day a way of identifying the UserForm control in focus through the function:
Function GetActiveControl() As Control
Dim SelCtrl As Control
Dim Ctrl As Control
For Each Ctrl In MultiPage1.Pages(3).Controls
If Ctrl.InSelection = True Then
Set SelCtrl = Ctrl
End If
Next Ctrl
Set GetActiveControl = SelCtrl
End Function
MsgBox GetActiveControl.Name
I’d like to take a step further and pass parameters to a class module and depending on which control (CommandButton) is pressed, take a different action.
I have in the Initialize section of the multipage UserForm:
Dim RtnButtons() As New NavBtnClass
Dim RtnBtnCnt As Integer
Dim RtnCtl As Control
RtnBtnCnt = 0
For Each RtnCtl In Trader.Controls
If Left(RtnCtl.Tag, 3) = "Rtn" Then
RtnBtnCnt = RtnBtnCnt + 1
ReDim Preserve RtnButtons(1 To RtnBtnCnt)
Set RtnButtons(RtnBtnCnt).RtnNavBtns = RtnCtl
End If
Next RtnCtl
and in the NavBtnClass class module
Private Sub RtnNavBtns_Click()
‘Return to Menu page
Trader.MultiPage1.Value = 0 ‘ I want to change the "0" to a variable
End Sub
Is it possible to pass a parameter to the class module changing the Multipage1.Value?
If I put a value in the Button Tag property I can use f.i. myTag=Right(Ctrl.Tag,1) to extract
the MultiPage number I want this particular Button to direct me to, but I don’t know how to pass this parameter to the class module!
Regards
Mats
Bookmarks