Return Key as Tab Key

Is there a way to use the Return Key instead of the Tab key to move to the next control without having to trap the key with the individual control events.

THANKS FOR YOU ASSISTANCE

Paul
PaddyoAsked:
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.

alokanantCommented:
As far as I know there is none.
A good idea is to use a control array. This simplifies the task, so that the code can be written only once for each type of control.

hth
alok.
0
GunsenCommented:
Private Sub Form_KeyPress(KeyAscii As Integer)
  If KeyAscii = 13 Then
    SendKeys Chr$(9), True
    KeyAscii = 0
  End If
End Sub
0
GunsenCommented:
Ans also, the form's KeyPreview must be enabled (true)...
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

caraf_gCommented:
Let me ask you a question.... WHY? Your users are running your product under windows. In windows the TAB key is used to move from one control to the next. Educate your users.
0
paul_tsekovCommented:
Hi, VBfan

The easier way for not writing much code in each Key_Pressed event sub is
using the indexed array of controls.

For example when you put a textbox on your form you name it
--
 Name Property : MyText
--

Now make the Index property 0
--
Index Property : 0
--

Now , you want to put another textbox on the form. So just name it with the same name:

--
 Name Property : MyText
--

Make it's index property 1
--
Index property : 1
--
And so on put TextBoxes names MyText
  and with ascending Index property

So now you have an array of indexed TextBoxes , each with the same name, but the different Index.
  Lets say we have made 10 TextBoxes
each with
 Name : MyText
 Index : i
  i changes from 0 to 9 for the different TextBoxes

So in your form's code module you should have the sub:

Private Sub MyText_KeyPressed(Index As Integer, KeyAscii As Integer)
' Here you could put the code:
  if KeyAscii=13 then
    Select Case Index  
      Case 0 to 8
        MyText(Index+1).SetFocus
      Case 9
        MyText(0).SetFocus
    End Select
  End If
End Sub

So that code should work by changing the focus to the next TextBox each time.
 When you've reached the last TextBox
 and then press Enter , the focus should go to the first TextBox.

  In case you have another ComboBox indexed group of ComboBoxes after the TextBoxes group, in the row below Case 9, instead of MyText(0).SetFocus you could write MyCombo(0).SetFocus
    and so on ...

Remember,
   try making groups of idetical items, using the indexed arrays.
  That surely makes life easier!!!

             Pavel Tsekov
      email : paul_tsekov@yahoo.com
 
 
 
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
alokanantCommented:
Hi Paul,

That's a good elaboration on my comment!

alok.
0
amebaCommented:
I agree with caraf_g's comment. Tab key is standard for Windows. It also increases productivity (forces users to use two hands for typing)

BTW,
    Select Case Index  
      Case 0 to 8
        MyText(Index+1).SetFocus
      Case 9
        MyText(0).SetFocus
    End Select
can be replaced with one line:
    MyText((Index+1) Mod 10).SetFocus
0
PaddyoAuthor Commented:
One of the reasons I wish to use the Return Key as well as the TAB key is that where there is a lot of numeric input, i.e. an accounting system, the numeric keypad is used. The Tab key is on the other side of the keyboard!! It is quicker to use the Enter Key.

Also - TAB maybe standard but customers are customers - they pay my wages.
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.