Retrieve ActiveControl.Name from Subform Control

Hi, I'm trying to retrieve the ActiveControl.Name from a subform control, but I recieve the following error.

"The expression you entered requires the control to be in the active window."


form = billing
subform = line_items

My code was placed in the subform's "on current" property so I should get the control name everytime I click through the records in the subform.

Form_line_items(code)

Private Sub Form_Current()

Dim ctlCurrentControl As Control
Dim strControlName As String
Set ctlCurrentControl = Screen.ActiveControl
strControlName = ctlCurrentControl.Name
msgbox strControlName

End Sub

I can't seem to figure out how to have this value returned.
Thanks for any help.
-Air
AirgazmAsked:
Who is Participating?
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.

Jokra_the_BarbarianCommented:
Try setting focus to a control before getting the active control. Also, use me.ActiveControl instead of Screen.ActiveControl.

Dim ctlCurrentControl As Control
Dim strControlName As String

Me.txt1.SetFocus
Set ctlCurrentControl = Me.ActiveControl

strControlName = ctlCurrentControl.Name
msgbox strControlName


0

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
AirgazmAuthor Commented:
ahh, I see how that works, thanks the focus worked.  
0
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 Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.