Determine Which Textbox has Focus

themach

New member
Local time
Today, 15:05
Joined
Sep 10, 2007
Messages
4
Hello,

I have a form with 24 textboxes and I wish to grab the name of the textbox that currently has the focus by using Screen.ActiveControl.Name. Instead of calling a function to get this information by creating all 24 textbox OnGotFocus events, is there a way to trigger the function under one event. Basically, I want to save the name of the textbox when the user places the cursor in it with as little code as possible. Thanks!

themach
 
Create a public sub, then link all your textboxes ongetfocus property to that sub. Trust me, this is the only way to do it, I did the same thing 2 years ago.
 
And you will not get away completely from putting something in the control event because that is what fires and that is how Access knows what is happening. If you don't put something in the event, whether the entire code or a function call, nothing will happen. So, you are semi-stuck in that you will have to put SOMETHING in ALL 24 got focus events, if you want the info.
 
Ok, thanks for the replies! Thought I could get around creating so many events, but it's not a problem to do. It will just be a lot more code :)
 

Users who are viewing this thread

Back
Top Bottom