For-Each-Next for Specific Object Type

  • Thread starter Thread starter jtertin
  • Start date Start date
J

jtertin

I have a form with several objects on it. I want to create a For-Each-
Next loop to gather information, but only for objects of LABEL type.
My current approach is to go through the entire collection, put an IF
statement between the EACH and NEXT of my loop to determine the
control type, and if it is a LABEL, continue processing (if not, move
on to the next control).

My only problem is - how can I determine the type of the control
inside of the loop?

Thanks for any help!
 
For Each ctl In Me.Controls
If TypeOf ctl Is Label Then
....
End If
Next ctl
 
Thanks!!!

Is there a way to perform a similar For-Each operation for each column
of the form's Record Source?

i.e.:

For Each column In Me.RecordSource
If column.Name = "TestString" Then
....
End If
Next column
 
Dim fld As DAO.Field

For Each fld In Me.RecordsetClone.Fields
If fld.Name = "TestString" Then

End If
Next fld
 
Back
Top