MrMegadeth
New Member
- Joined
- Jul 30, 2014
- Messages
- 5
My apologies as I know this has been asked many times but I cannot get this to work for my UserForm. I have highlighted the code in question in blue.
This is my class (BOL_BOXES) that will fire for the dynamically created comboboxes:
This is the UserForm Code - Parsed a bit due to length
The code compiles fine and the userform looks correct but I cannot get the class to fire. I am missing something since the Control is located on a multipage?
This is my class (BOL_BOXES) that will fire for the dynamically created comboboxes:
Code:
Public WithEvents btn As MSForms.ComboBox
Private Sub btn_Change()
Debug.Print "Change Working"
End Sub
Private Sub btn_Click()
Debug.Print " ClickWorking"
End Sub
Private Sub btn_DropButt*******()
Debug.Print "Working"
End Sub
This is the UserForm Code - Parsed a bit due to length
Code:
Private Sub UserForm_Initialize()
Dim BOLAmount As Integer
Dim pComboBoxes As Collection
Dim BOLCBox As BOL_Boxes
Dim cCtrl As MSForms.Control
Set pComboBoxes = New Collection
...
'add required controls to each page
For q = 1 To 12
TopNum = 6 + (18 * q) + 8 * q
Set cCtrl = Me.MultiPage1.Pages(i - 1).Controls.Add("Forms.combobox.1", "Chief" & q)
With cCtrl
.Left = 12
.Top = TopNum
.Width = 96
.RowSource = ("SandList" & i)
End With
[COLOR=#0000ff] Set cCtrl = Me.MultiPage1.Pages(i - 1).Controls.Add("Forms.combobox.1")
With cCtrl
.Left = 120
.Top = TopNum
.Width = 96
.Name = ("BOL" & q)
' based on my understanding this should create a collection and then add the new control cCtrl to the class
Set BOLCBox = New BOL_Boxes
Set BOLCBox.btn = cCtrl
pComboBoxes.Add BOLCBox[/COLOR]
End With
Set cCtrl = Me.MultiPage1.Pages(i - 1).Controls.Add("Forms.textbox.1", "Used" & q)
With cCtrl
.Left = 228
.Top = TopNum
.Width = 96
.TextAlign = fmTextAlignRight
End With
Next q
The code compiles fine and the userform looks correct but I cannot get the class to fire. I am missing something since the Control is located on a multipage?