tags:

views:

289

answers:

1

I have a VBA form (in Excel if that matters) that contains text boxes.

On three occasions, I have found myself pressing the tab key to navigate to the next control, but instead an actual TAB is being put in the text box.

The form normally acts as it should, but it does concern me that this gremlin is showing up sporadically.

It has shown up on Office 2003 as well as Office 2007 on two different computers.

Has anyone else encountered this problem and, if so, how did you fix it?

A: 

Set the TabKeyBehavior property to False to get "Tab jumps to next field" behavior.

Tomalak
Hmmm...it is set to False by default. I did a quick search on that property name and found this post:http://www.mrexcel.com/forum/showthread.php?t=44922 It had the following code snippit suggestion: Private Sub UserForm_Initialize()Dim Ctl As Control For Each Ctl In UserForm1.Controls MsgBox TypeName(Ctl) Select Case TypeName(Ctl) Case "TextBox" Ctl.TabKeyBehavior = False End Select Next CtlEnd SubI will try that and see if it works. Ty for quick reply.
ray023
@ray: This bit of code does nothing else but setting the property to `False` for all textboxes. That's nothing you couldn't do right in the designer, so why use it at all.
Tomalak
@Tom: Because when something doesn't work and you've tried the logical route...sometimes you need to try something illogical to see if you can make it work.Your suggestion was helpful, but not applicable.
ray023
@ray: Okay... so have you found the reason?
Tomalak
No Tom. Unfortunately not yet. And I reproduced the behavior again with with the code implemented above. Again, during another demo so I did not have time to troubleshoot.Closing the form and opening it back up fixed the behavior.Wish I could step into that VBA code to see what's going on. I'll keep my eyes posted for it again.It's like the TabKeyBehavior is set to true...even though it shouldn't be.
ray023