A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

For-Each-Next for Specific Object Type



 
 
Thread Tools Display Modes
  #1  
Old July 2nd, 2008, 07:45 PM posted to microsoft.public.access.forms
jtertin
external usenet poster
 
Posts: 31
Default For-Each-Next for Specific Object Type

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!
  #2  
Old July 2nd, 2008, 07:51 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default For-Each-Next for Specific Object Type

For Each ctl In Me.Controls
If TypeOf ctl Is Label Then
....
End If
Next ctl

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)


"jtertin" wrote in message
...
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!



  #3  
Old July 2nd, 2008, 08:20 PM posted to microsoft.public.access.forms
jtertin
external usenet poster
 
Posts: 31
Default For-Each-Next for Specific Object Type

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


  #4  
Old July 2nd, 2008, 10:01 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default For-Each-Next for Specific Object Type

Dim fld As DAO.Field

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

End If
Next fld

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"jtertin" wrote in message
...
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




 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:23 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.