Solved

Tab order

Posted on 2000-04-04
14
289 Views
Last Modified: 2010-05-02
I want the tab key to be associated with the Return key.If I had 3 text boxes on a form and my focus was on the first text box and I hit the enter key, I would like the tab to jump to the next text box. The keypress and keydown events don't capture the enter or tab key.
0
Comment
Question by:JohnRock
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 5
  • 2
  • +1
14 Comments
 
LVL 18

Accepted Solution

by:
deighton earned 50 total points
ID: 2683791
Private Sub Text1_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 13 Then

    Text2.SetFocus
   
End If
End Sub
0
 
LVL 18

Expert Comment

by:deighton
ID: 2683814
'If you do this as well in the same code

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = 13 Then KeyAscii = 0
End Sub
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2683818
2 ways:

Private Sub Text1_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        KeyAscii = 0
        SendKeys "{TAB}"
    End If
End Sub

Private Sub Text2_KeyPress(KeyAscii As Integer)
    If KeyAscii = vbKeyReturn Then
        KeyAscii = 0
        Text3.SetFocus
    End If
End Sub
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 10

Expert Comment

by:caraf_g
ID: 2683990
"I want the tab key to be associated with the Return key"

No you don't. Not if you want your application to behave like a good windoze application.

0
 
LVL 32

Expert Comment

by:Erick37
ID: 2684151
Depends on the application.  It's nice to use ENTER to move between single-line fields when entering data.  QuickBooks does this, for example.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2684176
Erick, do you really think so?

Compare

Test{left pinky}more text{left pinky}more text{left pinky}

to

Test{right pinky}more text{right pinky}more text{right pinky}

Much the same. Except, one is standard windows behaviour, the other is something that dates back to the good old days of DOS.

And I think it's time we left those days behind us.
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2684200
I'm not a touch typer, so it's easier for me to find the Enter key than the Tab key.
A single line TextBox does not use the Enter key anyway, so why not give it a use?  
The user will discover this very quickly and either use it or not.  The Tab functionality is not discarded.
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2684240
Haha, no Erick, that one won't wash with me.

If you're into mass data entry, believe me, you *are* a touch typist.

<wink>
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2684273
here od, iu exa.p;w of tpivj tuopmg

translated:
here is my example of touch typing
:)

0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2684335
<g>
That should have been

\jrtr od ,u rcs,[;r pg yupivj yu[omh/
0
 
LVL 10

Expert Comment

by:caraf_g
ID: 2684347
Or...

Y843B 8W J6 3SQJ0O3 9R 65697DY 56038HTL

(complete with a typing mistake, I think)

But seriously.... If you go to a place where they employ people whose job it is to enter large amounts of data, you can rest assured that they *will* employ touch typists to do the job.

Yes, I'll admit it... I am a touch typist. But I therefore can appreciate how easy it is to adapt to such a slight difference as changing from using your right pinky to your left pinky. It'll take an experienced touch typist at most a day to get used to it.
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2684531
Using <enter> as <tab> is ok. Using <tab> as <enter> is a no-no.

You can't easily intercept <tab> as it's not normally passed in the key events (It *is* but only if no control has the .TabStop property set True).

M
0
 
LVL 32

Expert Comment

by:Erick37
ID: 2684547
If I understand the question correctly, JohnRock wants to make the Enter key act as the Tab key.

"... I hit the enter key, I would like the tab to jump to the next text box"
0
 
LVL 12

Expert Comment

by:mark2150
ID: 2684575
Yep. I don't see a problem with that. I think you can do it at the form level if you set the forms KeyPreview to True then you can have:

private sub Form_KeyDown(keyascii as integer...)
if keyascii = vbEnter then keyascii = vbTab
end sub

I *think* that will work - haven't tested it.

M
0

Featured Post

[Webinar] How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses
Course of the Month11 days, 1 hour left to enroll

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question