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.
 

Excel Facts

Can you AutoAverage in Excel?
There is a drop-down next to the AutoSum symbol. Open the drop-down to choose AVERAGE, COUNT, MAX, or MIN
Check the Tab index property of each textbox, order the sequence from 0 onwards for the textboxes of each frame.
That is, if you have 3 textboxes in Frame1, then change the tab index to 0, 1 and 2 for the textboxes of Frame1, and so for each Frame.
Textboxes outside the Frame can have a higher numbering.
 
Upvote 0
Cross posted SetFocus with Frames not Working

While we do allow Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules). This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0
Hi Dante,

Either I haven't done what you said correctly or I just don't understand. I'm not very good with Excel, I'm just a beginner.
I have two frames, both with multiple textboxes, one frame has a TabIndex of 0 and the other a TabIndex of 1.
In each frame I have multiple Textboxes that have a TabInex sequence going from 0,1,2,3,4...15 and onward.
I also have multiple images and commandbuttons in the frames that also have a TabIndex.

I want it so that in the frame with the TabIndex of 0, after I press enter with the cursor in the textbox that has a TabIndex of 10, the SetCursor would then jump to the second frame into the Textbox that has a TabIndex of 0.

Thanks again.
 
Upvote 0
Please do not ignore the recommendations of the moderator, provide links to the forums where you put the same question.
 
Upvote 0
I have multiple Textboxes that have a TabInex sequence going from 0,1,2,3,4...15
Textboxes outside the Frame can have a higher numbering.

So the textboxes outside the frame must have a higher numbering, for example tabindex = 16, that way the cursor will jump from the last textbox of frame1 to the first textbox of frame2
 
Upvote 0
DanteAmor, my experience is that TabIndex, like Tab order is relative to its container, i.e. userform, Frame or Page.

Create a userform, add text box, add frame, add textbox inside the frame. Both textboxes will have a tab index of 0.
 
Upvote 0
DanteAmor, my experience is that TabIndex, like Tab order is relative to its container, i.e. userform, Frame or Page.
Create a userform, add text box, add frame, add textbox inside the frame. Both textboxes will have a tab index of 0.

I agree.

In this sequence the cursor jumps from frame 1 to frame 2

1586387669138.png


But in this sequence, the textbox outside the frames has tab index = 1, so the cursor jumps from frame 1 to the textbox outside the frames and then to frame 2
1586387729835.png


So, if there are more textboxes outside the frames, then use a numbering greater than that of the textboxes, in this example the largest is 2, then continue the numbering at 3,4,5

1586388007456.png
 
Upvote 0
Have you tested diagram three. When I set that up, I get Frame1.TabIndex = 0 Frame2.TabIndex = 1 and the text boxes get Index = 2,3,4.
 
Upvote 0
I get Frame1.TabIndex = 0 Frame2.TabIndex = 1 and the text boxes get Index = 2,3,4
Of course, when I put the outside textbox with tabindex = 1, the tabindex of frame2 changed to tabindex = 2, so the sequence was frame1-outside textbox-frame2 ?‍♂️.

You are right, the sequence of the tab index must be based on the number of frames
 
Upvote 0

Forum statistics

Threads
1,215,453
Messages
6,124,918
Members
449,195
Latest member
Stevenciu

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