I am trying to reference a a combobox_projecttype
in the sender
user form. It's a programmatically created form to which I add handle
'Declare variables
Dim NewForm_SmartHUB_Projects As New Form_SmartHUB_Projects
With NewForm_SmartHUB_Projects
.Name = "Form_SmartHUB_" & sender.text & "_" & iNewForm_SmartHUB_Projects
.Text = sender.text
AddHandler NewForm_SmartHUB_Projects.Activated, AddressOf DynamicForm_NewForm_SmartHUB_ProjectsActivated
iNewForm_SmartHUB_Projects +=1
End With
and then the sub looks like this
Sub DynamicForm_NewForm_SmartHUB_ProjectsActivated(ByVal sender As Object, ByVal e As EventArgs)
Debug.Print(sender.Name)
strProjectTypeFolderName = sender.combobox_projecttype.selecteditem
End Sub
Debug.Print
does return the correct name of the sender form however it seems that it doesn't see combobox_projecttype
in the sender
object.
iNewForm_SmartHUB_Projects
is a Long
that I just + 1
each next time to make different names for each userform.
What am I doing wrong and how do I reference control in programmatically created sender form?