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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Which control has Focus? 1

Status
Not open for further replies.

Soundsmith

Programmer
Feb 21, 2001
84
US
I've checked the archives, and had already tried "me.ActiveControl.Name"

But I get an error "The expression you entered requires the control to be in the active window"

I'm in the Current event and am just launching this screen. How do I get it to work?
David 'Dasher' Kempton
The Soundsmith
 
did you try to give focus to your control?
Another thing, make sure that when you write me.control you have to write that code on the same form where the control is it.
If you want to refer to a control in another form then you should do this:

Application.Forms("FormName").ActiveControl.SetFocus
msgbox Application.Forms("FormName").ActiveControl.Name

HTH
Alcar
 
Hi!

For a form with controls, the form doesn't get the focus until after the Current event runs. Let us know what you are trying to do and maybe we can come up with a workaround.

Jeff Bridgham
 
Alcar, I was in the form-Jebry gave me the clue - the form doesn't get focus until AFTER current-doesn't make sense to me why it should be that way, but OK. I found a way around the problem.

Thanks for the help. David 'Dasher' Kempton
The Soundsmith
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top