Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 296
  • Last Modified:



in my form there are 7 controls. how can I use Sendkeys to go through them like the Tab Key whenever i press Enter?
please give me a complete code showing the event where i use this property.

  • 2
1 Solution
Private Sub object_KeyPress([index As Integer,]keyascii As Integer)

The KeyPress event syntax has these parts:

Part Description
object --- An object expression that evaluates to an object in the Applies To list.
index --- An integer that uniquely identifies a control if it's in a control array.
keyascii --- An integer that returns a standard numeric ANSI keycode. Keyascii is passed by reference; changing it sends a different character to the object. Changing keyascii to 0 cancels the keystroke so the object receives no character.

if KeyAscii = 13 then sendkeys "{Tab}"
Richie_SimonettiIT OperationsCommented:
set form.keypreview property to True, in Keypress event of the form put this:
If KeyAscii = 13 Then SendKeys "{Tab}"
Richie_SimonettiIT OperationsCommented:
Just take in mind that it would set focus to every control in your form, not only text boxes.
Thanks for "A" grade.

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now