Results 1 to 14 of 14

Thread: TextBox1.SetFocus doesn't work (word2003)

Threaded View

  1. #8
    Addicted Member
    Join Date
    Jan 2002
    Location
    Glasgow, Scotland
    Posts
    202

    Re: TextBox1.SetFocus doesn't work (word2003)

    try something like:

    VB Code:
    1. Private Sub TextBox1_Change()
    2.  
    3. If TextBox2 = validinput Then
    4.     TextBox2.Select
    5.     Else
    6.         MsgBox "Enter valid input", vbOKOnly + vbCritical, "Input Error"
    7. End If
    8.  
    9. End Sub

    you can remove the validation part of the above.

    [EDIT]

    the above doesnt work as it works after each character input so try the below:

    VB Code:
    1. Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal Shift As Integer)
    2.  
    3. 'sets focus to next text object when ENTER is pressed
    4. 'KeyCode = 9 can be used for TAB key
    5. If KeyCode = 13 Then
    6.     TextBox2.Select
    7. End If
    8.  
    9. End Sub

    also, the things you are looking to do will work on a UserForm, as tab order and SetFocus can both be utilised.

    is a User form an option for you?
    Last edited by Br1an_g; Apr 16th, 2005 at 09:52 AM.
    if you fail to plan, you plan to fail

Posting Permissions

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



Click Here to Expand Forum to Full Width