How do I create and enum. a collection of controlls

D

doublediamonddon

I want to write a procedure to check some but not all of the controls on a
form. I would like to put the controls in a collection and loop through them
to determine if they are Null. I just can't seem to get the syntax right.
 
D

Dirk Goldgar

doublediamonddon said:
I want to write a procedure to check some but not all of the controls
on a form. I would like to put the controls in a collection and loop
through them to determine if they are Null. I just can't seem to get
the syntax right.

First, do you actually need to put them in a collection? How will you
know which ones you want to check? I've often used the Tag property of
controls to organize them into tagged groups, and then used logic like
this:

Dim ctl As Access.Control
Dim strList As String

For Each ctl In Me.Controls
If ctl.Tag = "NoNull" Then
If IsNull(ctl.Value) Then
strList = StrList & ", " & ctl.Name
End If
End If
Next ctl

If Len(strList) > 0 Then
MsgBox "Please enter values for " & _
Mid(strList, 3)
End If
 
Top