[AccessD] Form Controls

jwcolby jwcolby at colbyconsulting.com
Fri Oct 23 11:10:43 CDT 2009


If it were me I would use a collection.  Put the control itself into the collection, keyed on the 
cstr(Ctl.tabIndex).

dim MyCol as collection
set myCol = new collection

dim ctl as control

for each ctl in me.Controls
	mcol.add ctl, cstr(ctl.TabIndex)
next ctl

You can then use a for next loop to pull them back out in order of tabindex...

dim ctl as control

for I = 0 to col.Count-1
	set ctl = col(cstr(I))
	'examine the control here	
next I

A collection allows you to place anything into them (which includes pointers to controls).  It also 
allows you to use a KEY which essentially allows you to retrieve them by that key.  The key has to 
be a string however which is why we use cstr(ctl.tabindex).  So you place them in the collection 
keyed on the tab index.  Now the for next simply starts at 0 and works up, retrieving the controls 
one by one.  Since you start at 0, you retrieve the control at tabindex 0, and work up.

Pretty simple really.  This is aircode of course, but it should be close.

John W. Colby
www.ColbyConsulting.com


Tony Septav wrote:
> Hey Jack and Pat
> I thought the controls would follow the tab order when looping through, 
> but not on the form I am working with.  The code is not exactly what I 
> was looking for but it gives me a good starting point to do some modifying.
> 
> Thanks kindly for the help.




More information about the AccessD mailing list