Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Retrieve ActiveControl.Name from Subform Control

Posted on 2004-10-23
2
Medium Priority
?
965 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
Comment
Question by:Airgazm
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 11

Accepted Solution

by:
Jokra_the_Barbarian earned 1000 total points
ID: 12391330
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
ID: 12394923
ahh, I see how that works, thanks the focus worked.  
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

636 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