set focus with command button

J

Julie

I have a tab control with several tabs. I want to put a command button
"Next" on each tab page that will set the focus to the next tab I want. Then
on that tab page I will add another command button to go to the next tab I
want, etc. I think I need to use set focus but can't get it to work. Any
thoughts?
 
T

tina

SetFocus will probably work IF you set the focus to the first control in the
tab order on the "next" tab page; but you have to remember to update that
code if you change the order of controls on a tab page. or you can change
the value of the tab control, which is the usual way to do it: each page of
a tab control has a PageIndex value. the value of the tab control itself is
= to the PageIndex value of the currently selected page. to move to the page
which has an index value of 3, for instance, the code would be

Me!TabCtl0 = 3

replacing TabCtl0 with the correct name of your tab control. of course,
simply clicking the tab of any page will move the user to it. if you are
using command buttons to tightly control which tab page the user moves to
"next", you can use a single command button. just place it in the form's
Detail section, rather than on any tab page; it will "show through" on every
page. then write code to move to a specific page depending on what page the
user is currently on. for instance, if you want the user to go through
PageIndexes 0, 1, 2, 5, 4, 3 in that order, then

Select Case Me!TabCtl0
Case 0
Me!TabCtl0 = 1
Case 1
Me!TabCtl0 = 2
Case 2
Me!TabCtl0 = 5
Case 5
Me!TabCtl0 = 4
Case 4
Me!TabCtl0 = 3
Case 3
Me!TabCtl0 = 0
End Select

hth
 

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