Results 1 to 5 of 5

Thread: Using Shortcut Key to set focus?

  1. #1

    Thread Starter
    Lively Member THCfog's Avatar
    Join Date
    Oct 2002
    Location
    Michigan
    Posts
    86

    Using Shortcut Key to set focus?

    I was wondering if there was a way for this to work...

    My app currently has focus on "Text1".
    When the "Enter" key is pressed on the keyboard,I would like for my app to set focus to "Text2".

    I put info into text1 and would rather hit enter to move to the next textbox than deal with the mouse(save alot of tme)

    Is this easy to do?


    Thanks Ahead of time.

  2. #2
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    simulate a tab key

    VB Code:
    1. Private Sub Text1_KeyPress(KeyAscii As Integer)
    2.     If KeyAscii = vbKeyReturn Then
    3.         SendKeys "{tab}"
    4.         KeyAscii = 0
    5.     End If
    6. End Sub
    -= a peet post =-

  3. #3
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    KeyAscii = 0

    is to prevent the annoying beep
    -= a peet post =-

  4. #4
    Let me in .. techyspecy's Avatar
    Join Date
    Aug 2002
    Location
    Back to VBF.
    Posts
    2,456
    Originally posted by peet
    KeyAscii = 0

    is to prevent the annoying beep
    I'd say also include on error resume next and on error goto 0 in it.
    Sendkeys is friggin weird.

  5. #5
    -= B u g S l a y e r =- peet's Avatar
    Join Date
    Aug 2000
    Posts
    9,629
    yes, you are probably right... I never used this code much.

    He can also set focus to the text2 instead of using the sendkeys...
    -= a peet post =-

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