Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 2082
  • Last Modified:

VBA obtaining active object name

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
ryan_uk
Asked:
ryan_uk
  • 2
1 Solution
 
Wayne Taylor (webtubbs)Commented:
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
 
ryan_ukAuthor Commented:
Hi Wayne,

Thanks for your reply.

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

Horrible limitations with VBA :(

Ryan

0
 
Wayne Taylor (webtubbs)Commented:
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: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now