Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

Auto tab to next control

Discussion in 'Information Technology' started by Ricter, Jul 28, 2006.

  1. Ricter

    Ricter
    Expand Collapse
    Guest

    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
     
  2. Loading...

    Similar Threads Forum Date
    Opinion Is Autocomplete Evil? Some Women Take A Hard Look at Google ! Breaking News Nov 7, 2013
    Sikh News AutoZone sued for firing Everett Sikh Breaking News Sep 29, 2010
    India Singh: Centre Ready To Give Kashmir Autonomy Breaking News Aug 11, 2010
    India Paste tariff cards behind driver’s seat: Transport dept to automen Breaking News Jul 21, 2010
    Gursharan Kaur: India's First Lady's Autobiography Sikh Personalities Jun 1, 2010

  3. Michael H

    Michael H
    Expand Collapse
    Guest

    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
     
  4. Ricter

    Ricter
    Expand Collapse
    Guest

    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
     
  5. Michael H

    Michael H
    Expand Collapse
    Guest

    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
     

Share This Page