• Auto Tab To Next Field When Current Field Is Fille (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Auto Tab To Next Field When Current Field Is Fille (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    • This topic has 20 replies, 6 voices, and was last updated 21 years ago.
    Author
    Topic
    #402694

    I have a continous form with several fields that the operator must fill.

    What code can I use to advance the focus to the next field automatically when a field completely filled without pressing enter or tab keys?

    Thanks, John

    Viewing 3 reply threads
    Author
    Replies
    • #803525

      There may be a better way, but I would establish a “KeyPress” event on each field being checked for “completely filled” status. In the event code, you can accumulate the keystrokes in the field value, and when you decide that the field is filled (you didn’t specify a “filled” criteria), then programmatically shift the focus to the next field of interest (Me.fieldname.setfocus).

      — Jim

    • #803526

      There may be a better way, but I would establish a “KeyPress” event on each field being checked for “completely filled” status. In the event code, you can accumulate the keystrokes in the field value, and when you decide that the field is filled (you didn’t specify a “filled” criteria), then programmatically shift the focus to the next field of interest (Me.fieldname.setfocus).

      — Jim

    • #803546

      In the properties for the controls on the form you can set the “auto tab” to “yes”. Select all the controls you want it for at once, then you only have to set it once.

      • #803580

        Hi Frances

        That was easy, however auto tab is not available for combo boxes.

        I have two combo box one with a 1 character entry and the second with a 3 character entry, each have AfterUpdate event that have to fire when the field is filled.

        I tried several differents events without success.

        Can’t seem to get Len(FirstCombo) = 1 (this won’t return lenth)

        Any other suggestions?

        Thanks,

        John

        • #803602

          You can only use the auto tab on text boxes. So I guess I would create the combo box as unbound, and create a bound text box right next to it that is part of the tab order. Take the tab stop off of the combo box. Put an input mask and auto tab in the text box. It sounds like they’re probably going to know what they want to type in anyway, without using the drop-down from the combo. If they do use the combo, put an event in the after update to set the text box equal to the combo box. You could also add an event to the text box to check for valid data if you want it to limit to the list in the combo box.

          That’s what I’d do anyway, but I’m usually finding my own strange ways to do things. I did try it on a small form with 3 fields. With everything autotabing it goes to a new record after the last field. If you want to force them to save you’ll have to put a hidden field in to make it loop on the same record. There are probably better ways that I don’t know about. Hope this helps.

        • #803603

          You can only use the auto tab on text boxes. So I guess I would create the combo box as unbound, and create a bound text box right next to it that is part of the tab order. Take the tab stop off of the combo box. Put an input mask and auto tab in the text box. It sounds like they’re probably going to know what they want to type in anyway, without using the drop-down from the combo. If they do use the combo, put an event in the after update to set the text box equal to the combo box. You could also add an event to the text box to check for valid data if you want it to limit to the list in the combo box.

          That’s what I’d do anyway, but I’m usually finding my own strange ways to do things. I did try it on a small form with 3 fields. With everything autotabing it goes to a new record after the last field. If you want to force them to save you’ll have to put a hidden field in to make it loop on the same record. There are probably better ways that I don’t know about. Hope this helps.

        • #803700

          While the combo box has the focus, use FirstCombo.Text instead of just FirstCombo.

          FirstCombo.Text is the text that is currently in the text box part of the combo box.
          FirstCombo is the same as FirstCombo.Value; this is the “stored” value.

          • #803987

            Hi Hans

            Great news!

            What is the event should I test Len(ComboBox.text) = 1 assuming I have an AfterUpdate event associated with to combo as well?

            Thanks, John

            • #803989

              If you only want to allow a single character, you could use the change event, since it happens with each keystroke.

            • #803990

              If you only want to allow a single character, you could use the change event, since it happens with each keystroke.

            • #803993

              (Typo corrected by HansV – thanks to Support4John for pointing it out)

              To monitor what is happening as the user types, use the On Change event, for example

              Private Sub ComboBox_Change()
              If Len(ComboBox.Text) > 0 Then
              SendKeys “{TAB}”
              End If
              End Sub

              The After Update event will be executed if the On Change event boots the user out of the combo box. I would not use SetFocus or something like that in the After Update event to avoid conflicts.

            • #804058

              Thanks Charlotte & Hans

              Another super learning experience.

              There was typo here, If Len(ComboBox.Text > 0) Then

              John

              PS: Find attached demo from TechNoWini that further explains Events and When

            • #804060

              that demo was great. Thanks

            • #804061

              that demo was great. Thanks

            • #804059

              Thanks Charlotte & Hans

              Another super learning experience.

              There was typo here, If Len(ComboBox.Text > 0) Then

              John

              PS: Find attached demo from TechNoWini that further explains Events and When

            • #803994

              (Typo corrected by HansV – thanks to Support4John for pointing it out)

              To monitor what is happening as the user types, use the On Change event, for example

              Private Sub ComboBox_Change()
              If Len(ComboBox.Text) > 0 Then
              SendKeys “{TAB}”
              End If
              End Sub

              The After Update event will be executed if the On Change event boots the user out of the combo box. I would not use SetFocus or something like that in the After Update event to avoid conflicts.

          • #803988

            Hi Hans

            Great news!

            What is the event should I test Len(ComboBox.text) = 1 assuming I have an AfterUpdate event associated with to combo as well?

            Thanks, John

        • #803701

          While the combo box has the focus, use FirstCombo.Text instead of just FirstCombo.

          FirstCombo.Text is the text that is currently in the text box part of the combo box.
          FirstCombo is the same as FirstCombo.Value; this is the “stored” value.

      • #803581

        Hi Frances

        That was easy, however auto tab is not available for combo boxes.

        I have two combo box one with a 1 character entry and the second with a 3 character entry, each have AfterUpdate event that have to fire when the field is filled.

        I tried several differents events without success.

        Can’t seem to get Len(FirstCombo) = 1 (this won’t return lenth)

        Any other suggestions?

        Thanks,

        John

    • #803547

      In the properties for the controls on the form you can set the “auto tab” to “yes”. Select all the controls you want it for at once, then you only have to set it once.

    Viewing 3 reply threads
    Reply To: Auto Tab To Next Field When Current Field Is Fille (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: