Tab Order

G

Guest

I have a form with two Tab Control Pages. I've modified the tab order for
each page. Is there a way to link the two pages in the tab order? After
tabbing through the first Tab Control Page, I want to be able to go to the
first tab stop on the 2nd Tab Control Page. I can't find anywhere to link the
2nd page in the tab order of the first page.

Appreciate the help.
 
R

Rick Brandt

Eleanor said:
I have a form with two Tab Control Pages. I've modified the tab
order for each page. Is there a way to link the two pages in the tab
order? After tabbing through the first Tab Control Page, I want to
be able to go to the first tab stop on the 2nd Tab Control Page. I
can't find anywhere to link the 2nd page in the tab order of the
first page.

Appreciate the help.

Place a TextBox on the first page and make it last in the TabOrder. In its
GotFocus event run code to set focus to the desired control on the second page.
This TextBox must have its visible property set to True so it can receive focus
(however briefly), but you can make is so small that the user cannot see it.

A similar control on the second page can send the user back to the first page.
 
G

Guest

You could add an unbound text box to the first page and make it last in its
tab order. Set its properties as follows:

BackStyle: Transparent
BackColor: Same as underlying tab page
SpecialEffect: Flat
BorderStyle: Transparent

This will hide the control but still allow focus to move to it. The reason
for setting the BackColor property to match the underlying tab page is that
when the control gets focus its BackColor will momentarily be visible if it’s
a different colour to the tab page behind it. In its GotFocus event
procedure put:

Me.YourTabControl = 1
Me.SomeControl.SetFocus

where SomeControl is the first control on the second page which you want to
move focus to when the user tabs off the last visible control on the first
page. Note that a tab control'sVlaue property is zero based so 1 is the
second page.

In the tab control's Change event procedure put:

If Me.YourTabControl = 0 Then
Me.SomeOtherControl.SetFocus
End If

where SomeOtherControl is the first control in the tab order on the first
page. This will ensure that focus moves back to this control when the user
goes back to this page rather than staying on the invisible control.

Ken Sheridan
Stafford, England
 
G

Guest

Thanks for your help, Ken. I did everything you suggested, but wehn I tab to
the new text box, nothing happens; it's not moving onto the next page.

I created the text box, went to the "On Got Focus" selection of Events and
entered:

Private Sub Text59_GotFocus()
Me.Page2 = 1
Me.L_P_Org.SetFocus

End Sub

Private Sub Tab_to_next_page_GotFocus()

End Sub

It doesn't even go to the next page (which is called Page2).
 
R

Rick Brandt

Eleanor said:
Thanks for your help, Ken. I did everything you suggested, but wehn
I tab to the new text box, nothing happens; it's not moving onto the
next page.

I created the text box, went to the "On Got Focus" selection of
Events and entered:

Private Sub Text59_GotFocus()
Me.Page2 = 1
Me.L_P_Org.SetFocus

End Sub

Private Sub Tab_to_next_page_GotFocus()

End Sub

It doesn't even go to the next page (which is called Page2).

You don't need a line of code to change pages (and that wouldn't be how to do it
anyway). If you set focus to a control on a different page the page will
automatically change.
 
G

Guest

Thank you Rick. That worked perfectly.

Rick Brandt said:
You don't need a line of code to change pages (and that wouldn't be how to do it
anyway). If you set focus to a control on a different page the page will
automatically change.
 
G

Guest

You have referenced the page not the tab control itself. A tab control's
value is an integer representing the index of the current page. The first
page is 0, the second 1 etc. So by setting the control's value to 1 the
control's second page becomes its current page. But as Rick has pointed out
its not in fact necessary to do so, so omitting the line and simply moving
focus to the first control on page 2 should work.

Ken Sheridan
Stafford, England
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top