Sabotage
Board Regular
- Joined
- Sep 19, 2013
- Messages
- 58
Hey Wizzards,
I want to loop through of all controls in a user form and count comboboxes based on two criteria. Criteria 1 is to check if the combobox.name contains "cb_Discription*" and up until this point I am able to count them correctly. Criteria 2 would be to check if the combobox is empty or not? So if I find the first combobox named like that and is the combobox is not empty count add 1 to counter. I've tried the following but no luck:
I realize that when I declare CTRL as control, the Control object does not have a property .value or .text.
Any thoughts? Thanks in advance...
I want to loop through of all controls in a user form and count comboboxes based on two criteria. Criteria 1 is to check if the combobox.name contains "cb_Discription*" and up until this point I am able to count them correctly. Criteria 2 would be to check if the combobox is empty or not? So if I find the first combobox named like that and is the combobox is not empty count add 1 to counter. I've tried the following but no luck:
VBA Code:
Dim CTRL As Control
Dim COUNTER As Interger
For Each CTRL In Me.Controls
If CTRL.Name Like "cb_Discription*" And IsNull(CTRL.Value) = False Then ' also tried CTRL.Text<>""
COUNTER = COUNTER + 1
End If
Next
I realize that when I declare CTRL as control, the Control object does not have a property .value or .text.
Any thoughts? Thanks in advance...