Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Where is the next control identified?

6 views
Skip to first unread message

Chuck

unread,
Nov 10, 2009, 11:48:07 PM11/10/09
to
Screen.PreviousControl.Name provides the name of the control that last had
the focus. That's nice if you need to know where control came from, but
there doesn't seem to be a Screen.NextControl.Name or anything similar.

I have code that is executed OnLostFocus in which I would like to save the
name of the control that will be receiving the focus. This would allow me to
force the focus to some other control and then, after the required processing
of that control has finished, restore the focus to the control indicated by
the user.

Tom van Stiphout

unread,
Nov 11, 2009, 12:13:03 AM11/11/09
to
On Tue, 10 Nov 2009 20:48:07 -0800, Chuck
<Ch...@discussions.microsoft.com> wrote:

A simple solution would be to iterate over the Controls collection,
checking the TabIndex property:
dim ctl as control
for each ctl in me.controls
if ctl.TabIndex = Me.myControl.TabIndex + 1 then Msgbox "The next
control is " & ctl.Name
next
(of course you replace myObjectNames with yours)

Oh, but what if I used the mouse to move focus 3 controls ahead?

Your requirement is VERY curious. I think you are saying that when I
tab out of a control, you want OnLostFocus set focus somewhere else,
then set it to where I wanted to go in the first place. What's the
point of this side-step? Which would probably only last milliseconds?
Show us some code (stripped to the bare essentials) and we may be able
to suggest a better way.

-Tom.
Microsoft Access MVP

0 new messages