Need active control name

From a field on a excel form  (excel 2003),  I would like to get the active field name.  Can anyone help?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin LissOlder than dirtCommented:
Try Screen.ActiveControl.Name

which works in VB6


Userform1.ActiveControl.Name (replace Userform1 with the name of your userform)

tru-numbersAuthor Commented:
Yes, this works! But I have a control on a multipage control.  How do I obtain the active control when the user clicks on a field within the multipage?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

For a multi-page control, you can use:


Or, you could use (where MultiPage1 is the name of your multipage control):


And if the multipage is inside a frame:


If you don't know where the control might be you can try this code, which I just tested in a bunch of nested frames, tab strips, and multipage controls, to get the name of a checkbox control I clicked on the click event:

Sub getActiveControl()
Dim actCtrl As Control

    Set actCtrl = getControl(Me.ActiveControl)
    MsgBox actCtrl.Name
End Sub
Function getControl(ctrl As Control) As Control

    If TypeOf ctrl Is MSForms.Frame Then
        Set getControl = getControl(ctrl.ActiveControl)
    ElseIf TypeOf ctrl Is MSForms.MultiPage Then
        Set getControl = getControl(ctrl.Object.SelectedItem.ActiveControl)
        Set getControl = ctrl
    End If
End Function

Open in new window

@tru-numbers - did you have success with the code I posted?  Please advise if more assistance is needed.  The code, above, is tested and works.  If you need a demonstration workbook leveraging this code as more of an example, just ask.



Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
tru-numbersAuthor Commented:
Thanks for youe assistance
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.