Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / January 2005

Tip: Looking for answers? Try searching our database.

Getting Index the Controls Property in VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Den - 14 Jan 2005 16:05 GMT
Hi,

I am trying to get the index of the current control that has focus.
I tried:
Index = Me.Controls(Me.SNDetailSubform.Form.ActiveControl.Name).TabControl

Index = Me.Controls(Me.SNDetailSubform.Form.ActiveControl.Name).Index

Index = Me.Controls(Me.SNDetailSubform.Form.ActiveControl.Name).TabIndex

I was able to get tabindex, but tabindex is not what Controls uses as their
index.  Access uses tabindex.  Controls even gives an index to its labels.

How can I get the index property value the Controls is using?

Thanks

Signature

Den

MacDermott - 15 Jan 2005 03:29 GMT
First of all, the syntax you're using looks counterproductive, unless you
are actually trying to work with a control on your main form which has the
same name as the active control on the subform.

Second, I'm not sure why you need the index in the Controls collection, when
you can always refer to a control by its name instead of its index -
Me.Controls("MyControl") instead of Me.Controls(i).

However, if you really need to return that index, you could do it with a
function like this:
(WARNING:  AIR CODE)

Public Function ControlIndex(ctl as Control) as long
   Dim i as Integer
   For i=0 to Me.Controls.Count-1
       if me.Controls(i) is ctl then
           ControlIndex=i
           exit for
       end if
   next
End Function

HTH

> Hi,
>
[quoted text clipped - 12 lines]
>
> Thanks
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.