Problem using tab in TextBoxes not in Userform

E

Excel Curious

I've got six control Text boxes (TextBox1...TextBox6) they are NOT in a user
form. I want to be able to Tab between them and was trying to use the
following code, but found that it only worked for the first item and
thereafter I'd have to go in and "click" on the next text box to select it
before I could tab again to the next. Somehow the second use of the KeyDown
is not working as I thought.


Private Sub TextBox1_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
Dim fldTemp

If KeyCode = 9 Then
TextBox2.Activate
End If
End Sub

Private Sub TextBox2_KeyDown(ByVal KeyCode As MSForms.ReturnInteger, ByVal
Shift As Integer)
Dim fldTemp

If KeyCode = 9 Then
TextBox3.Activate
End If
End Sub

....and so on.
 
K

Ken

I copied your code to a worksheet module then made a copy for textbox3
that activated Textbox1. On the worksheet I have 3 textboxes. It tabs
from 1 to 2 to 3 and back to 1, and then around again with no
problems. You have a pretty neat way of doing this that works fine
for me. I can simply tab through the boxes with or without entering
anything.

I am using Excel 2003.

Thanks

Ken
 
K

Ken

How are your properties set up with regards to tabs for each text box?

autoload false
autotab false
enabled true
enterfiedlbehavior 0
enterkeybehavior false
imimode 0
tabkeybahavior false

I don't know what they all do, but, these are the ones that look most
likely to be relevant.

Good luck

Ken
 
E

Excel Curious

Yes, I can see that it works... now if I want to do the same thing in Word
will it work the same? I tried it and it doesen't. Any idea on how to adjust
the code or settings for a Word document?

Thank you for your help
 
K

Ken

It worked fine in Word for me.
Ken

Yes, I can see that it works... now if I want to do the same thing in Word
will it work the same? I tried it and it doesen't. Any idea on how to adjust
the code or settings for a Word document?

Thank you for your help









- Show quoted text -
 
E

Excel Curious

I'm actually working in Word, but there aren't as many programming
discussions. I discovered that the TextBoxes had to be "in line with text"
rather than "in front of text".

Now I've got another issue with my "tabs" not working when I link to the
document from my companies intranet. It opens Word in the Internet Explorer
Browser and somehow the "tab" code is disabled while all other macros in the
document continue to work as expected... any ideas.

The code I've ended up using is:
Private Sub TextBox1_KeyPress(ByVal KeyAscii As MSForms.ReturnInteger)
If KeyAscii = vbKeyTab Then
KeyAscii = 0
TextBox2.Select
End If
End Sub

I know how to change how the browser opens the document, but I cannot change
this setting on all users computers.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top