SetFocus with Frames not Working

JarekM

Board Regular
Joined
Nov 13, 2018
Messages
86
Hi,

I have a UserForm with several text boxes embedded into frames (used only as
a visual aid for grouping the text boxes).

Problem is, when the text boxes are embedded within a Frame, the SetFocus
doesn't work & the next textbox that is outside the frame is selected. I want it so when I press enter the next textbox in the frame would be selected.

Does anyone have any idea how to fix this?

Thanks in advance.
 
When you set up the tab order, objects on the form get focus according to that tab order. If an object on the form (e.g., a frame) contains other objects, then when that container object gets focus, the objects in that container get focus according to their tab order, then when the container is out of objects, the tab goes to the next object after the container on the form.

At the risk of complicating it unnecessarily, I've overlaid a tab order flow chart on this user form.

TabOrder.png

You can think of the overall tab order of the textboxes like this:

TextBox1 (Tab Order 0) -> overall Tab Order 0
TextBox2 (Tab Order 1) -> overall Tab Order 1
Frame 1 (Tab Order 2)
- TextBox1 (Tab Order 0) -> overall Tab Order 2.0
- TextBox2 (Tab Order 1) -> overall Tab Order 2.1
TextBox3 (Tab Order 3) -> overall Tab Order 3
Frame 2 (Tab Order 4)
- TextBox1 (Tab Order 0) -> overall Tab Order 4.0
- TextBox2 (Tab Order 1) -> overall Tab Order 4.1
TextBox4 (Tab Order 5) -> overall Tab Order 5
TextBox5 (Tab Order 6) -> overall Tab Order 6
Frame 3 (Tab Order 7)
- TextBox1 (Tab Order 0) -> overall Tab Order 7.0
- TextBox2 (Tab Order 1) -> overall Tab Order 7.1
TextBox6 (Tab Order 8) -> overall Tab Order 8
 
Upvote 0

Excel Facts

Move date out one month or year
Use =EDATE(A2,1) for one month later. Use EDATE(A2,12) for one year later.
I don't know how to edit my original post, so I'll link the cross-post here: Cross-Post Link

I have followed the steps in the images above, such as setting the first frame with the Tab Order of 0 and a second frame with a Tab Order of 1, with textboxes in each frame going from TabIndex 0,1,2,3...

But I do have images, commandbuttons, listboxes, etc... in my frames as well, so I think they are messing with the TabIndex.
 
Upvote 0

Forum statistics

Threads
1,216,084
Messages
6,128,722
Members
449,465
Latest member
TAKLAM

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