Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Returning Focus To Control Using Variables? 1

Status
Not open for further replies.

VoodooRage

Programmer
Oct 9, 2002
43
US
Hello, I am running a timer event that takes the focus from the active control. I have the following code to determine the active control at the time the focus is taken away.

' Determine the name of the "Active" form at
the time of the error.
Dim getfrm As Form
Dim getfrmname As String
Set getfrm = Screen.ActiveForm
getfrmname = getfrm.Name

' Determine the name of the "Active" Control at
the time of the error.
Dim getcntl As Control
Dim getcntlname As String
Set getcntl = Screen.ActiveControl
getcntlname = getcntl.Name

How can I use these two variables to return the focus to the active control?

I.E. Forms!ActiveForm!ActiveControl.setfocus

Thanks!


 
Try
Forms(ActiveForm).setfocus
Forms(ActiveForm).Controls(ActiveControl).setfocus
 
Thanks a bunch lameid! Your post worked beautifully and perfectly!

As MoJo JoJo might say... "This Site Woks Soh Hod"!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top