Jonas Offersen
New Member
- Joined
- Feb 13, 2018
- Messages
- 14
Good Morning Everyone
I am trying to make a dynamically created CheckBox show a UserForm OnChange.
I am using a Class module for this, but I keep getting the "object required" error...
Is this something you can help me out with? (pardon this wall of code)
The class I'm using looks like this:
Public WithEvents CBox As MSForms.checkbox
Public frm As UserForm
Dim iForm As UserForm
Private Sub CBox_Change()
iForm = FormActOptions
iForm.Show
End Sub
I declare a collection outside the sub.
Dim mColCBox As New Collection
Part of the Code generating the first userform:
Dim cBoxEvent As ClassCBox
Exist = rCell.Offset(, 8) 'it exist now
Set iCheck = Me.Controls.Add("Forms.CheckBox.1", "CheckBox_" & CStr(i), True)
Set acmd = Me.Controls.Add("Forms.TextBox.1", "TextBox_" & CStr(i), True)
Set iFormidler = Me.Controls.Add("Forms.Textbox.1", "CountBox_" & CStr(i), True)
With iCheck 'create a dynamic checkbox
.Top = top_ + 18
.Left = FormIActivities.Label1.Left
.Caption = rCell.Value
.Width = FormIActivities.Label1.Width
If (rCell.Value = "Rabat") Then
.Font.Bold = True
End If
End With
Set cBoxEvent = New ClassCBox
Set cBoxEvent.CBox = iCheck
Set cBoxEvent.frm = Me
mColCBox.Add cBoxEvent
OBS! To avoid crowding this place with code, I chose to cut out only what I think is needed. If you want the full code of this sub, do give me a headsup!
Thank you again for trying to help me out!
I am trying to make a dynamically created CheckBox show a UserForm OnChange.
I am using a Class module for this, but I keep getting the "object required" error...
Is this something you can help me out with? (pardon this wall of code)
The class I'm using looks like this:
Public WithEvents CBox As MSForms.checkbox
Public frm As UserForm
Dim iForm As UserForm
Private Sub CBox_Change()
iForm = FormActOptions
iForm.Show
End Sub
I declare a collection outside the sub.
Dim mColCBox As New Collection
Part of the Code generating the first userform:
Dim cBoxEvent As ClassCBox
Exist = rCell.Offset(, 8) 'it exist now
Set iCheck = Me.Controls.Add("Forms.CheckBox.1", "CheckBox_" & CStr(i), True)
Set acmd = Me.Controls.Add("Forms.TextBox.1", "TextBox_" & CStr(i), True)
Set iFormidler = Me.Controls.Add("Forms.Textbox.1", "CountBox_" & CStr(i), True)
With iCheck 'create a dynamic checkbox
.Top = top_ + 18
.Left = FormIActivities.Label1.Left
.Caption = rCell.Value
.Width = FormIActivities.Label1.Width
If (rCell.Value = "Rabat") Then
.Font.Bold = True
End If
End With
Set cBoxEvent = New ClassCBox
Set cBoxEvent.CBox = iCheck
Set cBoxEvent.frm = Me
mColCBox.Add cBoxEvent
OBS! To avoid crowding this place with code, I chose to cut out only what I think is needed. If you want the full code of this sub, do give me a headsup!
Thank you again for trying to help me out!