Sendkeys

Hi,

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.

thanx
LVL 1
asnsAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

fluglashCommented:
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}"
0
Richie_SimonettiIT OperationsCommented:
set form.keypreview property to True, in Keypress event of the form put this:
If KeyAscii = 13 Then SendKeys "{Tab}"
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
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.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.