[AccessD] Cycling through subform controls

Heenan, Lambert Lambert.Heenan at AIG.com
Thu May 22 11:55:15 CDT 2003


If you are executing this code *in the form* who's controls you want to
iterate, then you do not need to use the Forms collection at all. Just
use...

	For Each ctlC in Me
		...
	Next ctlC

This kind of loop will run fine in a form or in a subform: as long as the
code is actually in the form in question, as 'Me' refers to the current
form.

To loop though a sub form's controls from code in the parent form you would
use...

	For Each cltC in Me.NameOfSubFormCONTROL.Form
		...
	Next cltC

Lambert


> -----Original Message-----
> From:	Dale Kalsow [SMTP:dkalsow at yahoo.com]
> Sent:	Thursday, May 22, 2003 12:35 PM
> To:	accessd at databaseadvisors.com
> Subject:	[AccessD] Cycling through subform controls
> 
> 	I have the following line of code:
> 
> 	For Each ctlC In Forms(Me.Name)
> 
> 	 
> 
> 	It works great if it is the main form but if I try and use it in a
> subform it throws an error.
> 
> 	 
> 
> 	Does anyone know the correct line of code to use in a subform.  I am
> trying to have the subform cycle though its controls.
> 
> 	Thanks!
> 
> 	Dale Kalsow
> 


More information about the AccessD mailing list