PDA

View Full Version : Solved: conditions for multiplecomboboxes



white_flag
06-01-2011, 01:38 AM
Good morning,

Today is a nice day (sunny day). Anyway, what I need to do and I can not:
I have 15 comboboxes and I like to put an condition like this
If all comboboxes are empty do the code if not do something else:



For i = 1 To 15
If Me.Controls("ComboBox" & i).Text = "" And Me.Controls("ComboBox" & i + 1).Text = "" etc .... Then
code 1
Else
code 2
End If
Next

GTO
06-01-2011, 01:42 AM
Not tested, but maybe:

Dim bolNotEmpty As Boolean
For i = 1 To 15
If Not Me.Controls("ComboBox" & i).Text = vbNullString Then
bolNotEmpty = True
Exit For
End If
Next

If Not bolNotEmpty Then
'code 1
Else
'code 2
End If

white_flag
06-01-2011, 01:53 AM
perfect

thx Mark

mikerickson
06-01-2011, 06:57 AM
Here's another aproach For i = 1 To 15
If Not Me.Controls("ComboBox" & i).Text = vbNullString Then
' code 2
GoTo Skip
End If
Next

'code1

Skip:
'continue