[AccessD] Form Controls

Charlotte Foust cfoust at infostatsystems.com
Fri Oct 23 10:36:30 CDT 2009


If you're talking about in design view, the controls follow the order in
which they were added, not the tab index, which can be changed.

Charlotte Foust 

-----Original Message-----
From: accessd-bounces at databaseadvisors.com
[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
Sent: Friday, October 23, 2009 8:24 AM
To: Access Developers discussion and problem solving
Subject: Re: [AccessD] Form Controls

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.


Jack and Pat wrote:

>Tony,
>
>I found this from Allen Browne:
>
>2/16/2006 4:10:25 PM    Re: accessing controls by tab index
>
>You could loop through the form's Controls collection, identify those 
>that
>  
>have a TaxIndex (Labels don't, for instance), and load an array based 
>on the
>
>  
>TabIndex of each one:  
>  
>Function LoopControls(frm As Form)
>  
>Dim ctl As Control
>  
>Dim strControl() As String
>  
>Dim i As Integer
>  
>Dim iMax As Integer
>  
>ReDim strControl(0 To frm.Controls.Count - 1)
>  
>For Each ctl In frm.Controls
>  
>If HasProperty(ctl, "TabIndex") Then
>  
>i = ctl.TabIndex
>  
>strControl(i) = ctl.Name
>  
>If i > iMax Then
>  
>iMax = i
>  
>End If
>  
>End If
>  
>Next
>  
>For i = 0 To iMax
>  
>Debug.Print i, strControl(i)
>  
>Next
>  
>End Function
>  
>Public Function HasProperty(obj As Object, strPropName As String) As 
>Boolean
>
>  
>'Purpose:   Return true if the object has the property.  
>  
>Dim varDummy As Variant
>  
>On Error Resume Next
>  
>varDummy = obj.Properties(strPropName)
>  
>HasProperty = (Err.Number = 0)
>  
>End Function
>  
>Looping seems to be in tab order anyway.  
>  
>You might want to examine the TabStop property as well.  
>  
>--
>  
>Allen Browne - Microsoft MVP.  Perth, Western Australia.  
>  
>Tips for Access users - http://allenbrowne.com/tips.html
>  
>
>-----Original Message-----
>From: accessd-bounces at databaseadvisors.com
>[mailto:accessd-bounces at databaseadvisors.com] On Behalf Of Tony Septav
>Sent: Friday, October 23, 2009 7:50 AM
>To: Access Developers discussion and problem solving
>Subject: [AccessD] Form Controls
>
>Hey All
>Is there a simply way to loop through the controls on a form based on 
>their tab order?
>
>Thanks
>Tony
>  
>

-- 
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com




More information about the AccessD mailing list