How to set Tab Order in code?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a TabControl with 2 tabs. In the 1st tab, there's a command button
named cbGoTo2ndTab which opens 2nd tab (PageIndex=1). My question is I have 2
subforms in the 2nd tab, how do I set the focus to the bottom subform in the
2nd tab instead of the top one when the button is clicked?

I know I can set the order in Tab Order, but I only want the bottom subform
to attract focus first ONLY when the button is used. How to achieve this?
Thanks

--- start of my code ---
Private Sub cbGoTo2ndTab_Click()
' Switch to 2nd tab (PageIndex =1)
Me.Parent.TabCtl.Value = 1
End Sub
--- end of my code ---
 
Sam,

It looks like the command button is also in a subform, is that right?
In any case, it will not be necessary to toggle the tab page, so you can
eliminate this line from your code. Try it like this...

Private Sub cbGoTo2ndTab_Click()
Me.Parent!BottomSubform.SetFocus
End Sub
 
Back
Top