My program is about to complete but there is a minor problem.
I have a combo box and dynamically created checkboxes. When the combo box item changes the no. of checkboxes that will be displaced will change, what I want is when combo box item changes all the controls on the userform should be automatically removed. In short, I want to remove the controls of userform on combo box change.
I am using the below code but its giving me an "Invalid Argument" error.
Code:
Public Sub chkbox_remover(loop_ulimit As Integer, ctrl_name As String)
Dim looper As Integer
If eqp_count > 0 Then
If loop_ulimit > 0 Then
For looper = 1 To loop_ulimit
frmEqpDetails.Controls.Remove ctrl_name & looper
Next looper
End If
End If
End Sub
In the above code "loop_ulimit" is the maximum number of controls in the userform. "eqp_count" is the count of checkboxes that will appear in userform on combo box selection and "looper" is the no. of controls on userform. I had already defined "eqp_count" as a global variable.