Thanks, but I just realized that there is a problem with the code below.
Control1 would never be able to receive the focus, which is the reason for
the existence of the Shift-Tab issue I described below. Try the following
instead, which should be a better solution. "Control0" refers to the name of
the control which appears before Control1 in the tab order.
Private Sub Control1_GotFocus()
Dim ctl As Control
Set ctl = Screen.PreviousControl
If ctl.name = "Control0" Then
If Not (IsNull(Me.Control1)) Then
Me.Control2.SetFocus
End If
End If
End Sub
"Ricter" wrote:
> Thank you Michael, and good points.
>
>
>
> "Michael H" wrote:
>
> > Hi.
> >
> > In the Got Focus event of that control, it would be possible to check for
> > Null, and if so, loop through all controls on the form until you found the
> > one for which the tab index is the next highest than the tab index for the
> > current control, and then set the focus to it. However, this seems to be a
> > bit more trouble than it is worth, unless you are constantly rearranging your
> > controls. I think the best way would be to refer to the control directly:
> >
> > Private Sub Control1_GotFocus()
> > If Not (IsNull(Me.Control1)) Then
> > Me.Control2.SetFocus
> > End If
> > End Sub
> >
> > If you also want to check for an empty string in addition to Null, change
> > the If statement to something like:
> > If Not(Me.Control1 & "") = "" Then
> >
> > By the way, have you considered the fact that your user will not be able to
> > use Shift-Tab to cycle through the controls in reverse order if this is
> > implemented? If a non-null Control1 automatically gives Control2 the focus,
> > a Shift-Tab from Control2 will appear to do nothing, since the focus will be
> > automatically set right back to Control2.
> >
> > -Michael
> >
> >
> > "Ricter" wrote:
> >
> > > if the current control is not null. What would be the best way to do this?
> > > Do I have to refer to the next control, or is there a way to "resume tab
> > > stops"?
> > >
> > > tia
|