Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

UserForm Tab Order problem

Status
Not open for further replies.

mintjulep

Technical User
Aug 20, 2004
1,551
JP
I have a problem with the tab order on a userform that I cannot understand.

My form has the following controls of interest:

ComboBox1: Tab order = 0
TextBox1: Tab order = 1
TextBox2: Tab order = 2
CommandButton1: Tab order = 3
CommandButton2: Tab order = 4
Frame1: Tab order = 4

All have their .tabstop = true

If I run the form and just tab-tab-tab... the controls follow the tab order properly.

In TextBox2_Change
I validate the information from ComboBox1, TextBox1 and TextBox2.
If valid I set CommandButton1.Enabled = False

My expectation is that after entering information into TextBox2 and pressing tab that CommandButton2 will get the focus

However Frame1 gets the focus.

I tried to explicitly set CommandButton2.setfocus in TextBox2_change. However that results in Run-time error '2147467259 (80004005)': Unspecified error.

I'm very confused, as this seems like a straight-forward thing.
 
Why not this ?
Frame1: Tab order = [!]5[/!]

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Typo in my Original Post.

Frame1: Tab order = 5 in actuality.
 
What are other event procedures in the userform? Change error trapping to "break on all errors" and see what code causes this error.

combo
 
How are ya mintjulep . . .

For starters I'd use the [blue]BeforeUpdate[/blue] event. This event can be cancelled if your validation should fail.

mintjulep said:
[blue]My expectation is that after entering information into TextBox2 and pressing tab that CommandButton2 will get the focus. However Frame1 gets the focus.[/blue]
I would have the same expectations however ... there are times you have to specifcally set the focus yourself ...

Code:
[blue]Me.[b]CommandButton2Name[/b].SetFocus[/blue]

Give it a shot.


See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
Based on what you have posted, something is wrong!

If there are no other controls that could be interfering I would consider some corruption. Perhaps recompile the VBA Project, or maybe export the userform (or even all elements of the Project) and import into a new project and see if it works there.

Enjoy,
Tony

------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top