Solved

VBA obtaining active object name

Posted on 2007-03-17
3
2,009 Views
Last Modified: 2013-12-20
Hello all,

In VBA I am trying to find a way to call the name of the active object within the form.

Me.ActiveControl works for most part however if I have a multipage or tabstrip within the form the ActiveControl returned is always the multipage/tabstrip name, not the object contained within it.

So if I am trying to call the name of TextBox1 within MultiPage1 how would I do this?

Ryan
0
Comment
Question by:ryan_uk
  • 2
3 Comments
 
LVL 47

Expert Comment

by:Wayne Taylor (webtubbs)
ID: 18741972
Hi Ryan,

Try this....

     Dim ActCtrl As String
     If LCase(ActiveControl.Name) Like "multipage*" Then
          Dim pg As Page
          Set pg = ActiveControl.SelectedItem
          ActCtrl = pg.ActiveControl.Name
     Else
          ActCtrl = ActiveControl.Name
     End If
     MsgBox ActCtrl

Regards,

Wayne
0
 

Author Comment

by:ryan_uk
ID: 18746966
Hi Wayne,

Thanks for your reply.

VBA doesn't use ActiveControl.SelectedItem is this a standard VB function?

Horrible limitations with VBA :(

Ryan

0
 
LVL 47

Accepted Solution

by:
Wayne Taylor (webtubbs) earned 50 total points
ID: 18751842
Ryan,

It's true that intellisense doesn't show it, but have you tried my example? It does work in VBA. SelectedItem is a property of MultiPage, so will work in this example.

Wayne
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA filters 2 71
vb6 - Transfer from MSHFlexgrid1 to xls issue 8 61
VB6 - Scroll Mouse wheel on Picturebox 13 96
VBA Replace Function - What am I missing? 3 21
Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question