How do I create and enum. a collection of controlls

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top