+ Reply to Thread
Results 1 to 8 of 8

Switching between textboxes

  1. #1
    Registered User
    Join Date
    09-25-2007
    Posts
    20

    Switching between textboxes

    I have a form which has 19 textboxes aligned in a column that the user inputs values into. Right now they have to click in each textbox to enter data.

    Is there a way that after entering a value, the next textbox down can be selected using either the down arrow or when hitting "Enter" (also preferrably switching to the textbox above when hitting the up arrow).

    I should note that I currently have some code being run everytime a textbox is changed to update the output fields (using textbox1_change() routine).

    Any help would be greatly appreciated, I've looked around and haven't been able to find anything that works as of yet.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200
    Do you mean on a UserForm? If you are then you can set the Tab order of the TextBoxes by right clicking on the UserForm in the VB Editor & selecting Tab Order.
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Registered User
    Join Date
    09-25-2007
    Posts
    20
    It's not on a userform, but on a worksheet that I've added a data entry area.

  4. #4
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    This seemed to work for me:
    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    09-25-2007
    Posts
    20
    I tried using something like that, but I really need to retain the textbox1_change() event, because I need the data to be updated real-time.

    When I use the textbox1_KeyDown() routine the sata doesn't update with every keystroke, but rather with the next keystroke. This produces mis-leading output values.

    Is there anyway to include the KeyCode logic within a _change() routine?

  6. #6
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Using the following code (containing both change and keydown) my cells A1, A2, & A3 all change in realtime.
    Can you attach a sample so we can see the issue more clearly?
    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-25-2007
    Posts
    20
    I actually just tried that before you posted and it works great! I was not aware you could run them at the same time.

    Two smaller issues:

    1. Can you select all the text in a textbox after the .activate? That way the user doesn't have to delete what is in there manually

    2. In the following code, I've written it for textbox1 on my sheet. Can I write one section of code that will drop to the next textbox based on the current textbox? Rather than write the below code for all 19 of my textboxes (i.e. if in textbox5, then go to either textbox 4 or 6)

    Please Login or Register  to view this content.

  8. #8
    Valued Forum Contributor
    Join Date
    04-11-2006
    Posts
    407
    Quote Originally Posted by jcup
    Two smaller issues:

    1. Can you select all the text in a textbox after the .activate? That way the user doesn't have to delete what is in there manually

    2. In the following code, I've written it for textbox1 on my sheet. Can I write one section of code that will drop to the next textbox based on the current textbox? Rather than write the below code for all 19 of my textboxes (i.e. if in textbox5, then go to either textbox 4 or 6)
    1. See this link for example using .SelStart and .SelLength: Select text in textbox

    2. If this is possible, it is beyond my abilities at this time. I recommend just copy/pasting and changing the numbers for each textbox.

    Hope that helps.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1