Solved

VBA obtaining active object name

Posted on 2007-03-17
3
1,982 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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now