Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Control Collections: Anyway to control the index of each control? 1

Status
Not open for further replies.

xtreme1

Programmer
May 27, 2000
51
US
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;I'm wondering, is there anyway I can possibly predetermine what the index of a control will be on a form?&nbsp;&nbsp;I need to be able to cycle through controls, and doing it by number is just convenient(and semi-necessary) the way I have chosen to handle the situation.&nbsp;&nbsp;Unfortunately, my incremented integer variable is not coordinated well with my controls and their associated indexes.&nbsp;&nbsp;So now what occurs is that the wrong controls are influenced.&nbsp;&nbsp;Any thoughts on this are appreciated, if you need me to expand on the problem more for you in any way just let me know.<br>&nbsp;&nbsp;&nbsp;&nbsp; <p>xtreme1<br><a href=mailto:rbio@excite.com>rbio@excite.com</a><br><a href= > </a><br>
 
what about tab index<br>The following example reverses the tab order of a command button and a text box. Because TextBox1 was created first, it has a TabIndex property setting of 0 and Command1 has a setting of 1.<br><br>Sub Form_Click()<br> Me!Command1.TabIndex = 0<br> Me!TextBox1.TabIndex = 1<br>End Sub<br><br>I assume this is what you had in mind
 
&nbsp;&nbsp;&nbsp;&nbsp;Not quite what I have in mind.&nbsp;&nbsp;I want to be able to reference a control and *all* of it's properties through the control collection using only a numerical index representation.&nbsp;&nbsp;For example: <br><br>Me.Controls(1).Enabled = True 'Enable first control<br>Me.Controls(4).Text = &quot;Not found&quot;<br><br>&nbsp;&nbsp;&nbsp;&nbsp;The above examples have no relation to what I'm trying to accomplish in terms of after I've figured out how to use the control collections properly.&nbsp;&nbsp;They are merely examples of the basic concept.&nbsp;&nbsp;Mostly what I'm after is the ability to iterate through a group of controls without referencing by name. <p>xtreme1<br><a href=mailto:rbio@excite.com>rbio@excite.com</a><br><a href= > </a><br>
 
The &quot;Controls&quot; collection is indexed in the order the controls were originally added to the form.<br><br>If you are trying to set some of the control properties (but only for certain types of control), you can use the &quot;TypeName&quot; function or &quot;TypeOf&quot; if statement.<br><br>If TypeOf Me.Controls(1) Is TextBox Then<br>...<br><br>If TypeName(Me.Controls(1)) = &quot;TextBox&quot; Then<br>... <p>Jim Conrad<br><a href=mailto:JimConrad@Consultant.com>JimConrad@Consultant.com</a><br><a href= > </a><br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top