1
votes

I have a continuous form with 5 combo boxes in each record. How do I loop through each of these boxes when I click on a button in the active record to find if the boxes are not null. I want to loop through only the active record and not entire record set.

2

2 Answers

0
votes

Try this

 Dim ctl As Control
    For Each ctl In Screen.ActiveControl.Parent
       If TypeName(ctl) = "ComboBox" Then
          If IsNull(ctl) Then
            MsgBox ctl.Name & " combo is null"
          Else
            MsgBox ctl.Value
          End If
       End If
    Next
0
votes

If comboboxes have similar names like cboTest1, cboTest2, etc., something like:

For Each x = 1 to 5
    If IsNull(Me("cboTest" & x)) Then
        MsgBox "Combobox " & x & " needs data selected."
    End If
End If