Solved

Retrieve ActiveControl.Name from Subform Control

Posted on 2004-10-23
937 Views
Last Modified: 2012-08-14
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
0
Question by:Airgazm
    2 Comments
     
    LVL 11

    Accepted Solution

    by:
    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
     

    Author Comment

    by:Airgazm
    ahh, I see how that works, thanks the focus worked.  
    0

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone. Privacy Policy Terms of Use

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Introduction When developing Access applications, often we need to know whether an object exists.  This article presents a quick and reliable routine to determine if an object exists without that object being opened. If you wanted to inspect/ite…
    A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
    Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
    Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

    860 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

    14 Experts available now in Live!

    Get 1:1 Help Now