Automatically Going To Next Tab Index

  • Hello. I need some help with VBA. I've been googling and looking in this forum but couldn't find what I need.


    Basically, I have a form with text boxes and would like to automatically go to next textbox once I hit enter in one text box, or even better, once it reaches its maximum characters allowed.


    I type text in textbox with tab index 0, and when I hit enter, the cursor automatically goes to textbox with tab index 1 and then 2, and so on. If you don't know what I mean, it's like when you buy software and enter the CD key. Usually you don't have to hit tab or anything, it skips to next tab by itself. Same with when you go to a website and sign up for something. Sometimes you don't have to hit tab, or even enter. Once it reached it's character limit, it moves onto next tab.


    Thanks for the help...

  • Re: Automatically Going To Next Tab Index


    hI m4r1u5 - as long as you have TAB Stop property set to TRUE and have an increasing TAB Index, then when you press Enter or TAB it should automatically go to the next control (whatever the type is).


    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Automatically Going To Next Tab Index


    You can also adjust your maxlength of your TextBox properties to only allow a certain amount of characters.
    You could code if you want, here is an example if you wanted to limit Textbox1 to only 4 characters:


    Code
    Private Sub TextBox1_Change()
    If Len(Sheet1.TextBox1.Value) = 4 Then Sheet1.TextBox2.Activate
    End Sub
  • Re: Automatically Going To Next Tab Index


    Also, if you want to 'jump' to the next tab stop after x amount of characters are entered then you could do something like this in the change event of the textbox (in this case, the first textbox).


    Code
    Private Sub TextBox1_Change()
    If Len(TextBox1.Text) > 3 Then 'if more than 4 characters jump to next tab stop.
        Controls(TextBox1.TabIndex + 1).SetFocus
    End If
    end sub



    Ger

    _______________________________________________
    There are 10 types of people in the world. Those that understand Binary and those that dont. :P


    Why are Halloween and Christmas the same? Because Oct 31 = Dec 25... ;)

    _______________________________________________

  • Re: Automatically Going To Next Tab Index


    Thanks a lot...


    I should of played a little more with the settings before thinking there needs to be special code to do that.


    I actually figured out my other problem too, with automatically going to next tab when reaching character limit.


    You just have to make "AutoTab" true in the settings.


    Nice...

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!