Focus issue on user form

LoTech

New Member
Joined
Jul 11, 2011
Messages
1
I have a user form with several text boxes and command buttons. I have the tab order setup like this:
txtBox1 - tab 0
cmdButton1 - tab 1
txtBox4 - tab 2
cmdButton2 - tab 5

When users enter text in txtBox1 they can hit ENTER<enter> twice which activates cmdButton1, this is desired behavior.

When certain text is entered in txtBox1, code changes focus to txtBox4 where the user enters additional text, this is desired behavior. However when they hit <enter> ENTER in txtBox4 the focus then shifts to cmdButton2, and I need it to activate cmdButton1 instead.

I have tried several ways like using the txtBox4_exit to call cmdButton1 and/or txtBox1.SetFocus. Setting focus has proven to be not very intuitive. It seems when focus switches between command buttons and text boxes things just go wacky. Throw in a few MsgBoxes and it just gets more weird.</enter></enter>
 

Excel Facts

How to find 2nd largest value in a column?
MAX finds the largest value. =LARGE(A:A,2) will find the second largest. =SMALL(A:A,3) will find the third smallest

Forum statistics

Threads
1,224,600
Messages
6,179,833
Members
452,947
Latest member
Gerry_F

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top