Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open form on a specific tab 1

Status
Not open for further replies.

PikPim

Programmer
Jul 25, 2006
15
CA
Hi, I've got a form in which there a like 5 tabs, By default when I open the form it goes to the first tab but i would like to know if there is a command in vba that allow me to specify which tab should be opened (i need the code because most of the time it must open on the first tab which is fine now, but sometimes, it needs to open to the 4th tab)

Thanks in advance
 
Since tabs are controls, you should be able to open the form, then use something like:

Me.tabname.SetFocus

This would probably be best in in the onLoad event of the form. I think this could also be done by setting the focus directly on a textbox on that tab.

Hope this helps.

"If you say you can, or you say you can't, you're right!"
-- Henry Ford
 
Perhaps:
Code:
Private Sub Form_Load()
'Using the index number, starting at 0
Me.TabCtl0.Pages(3).SetFocus
'Or using the page name
Me.TabCtl0.Pages("Page4").SetFocus
End Sub
 
Both of the above answers will work, after wrapping them with code to determine whether 1st tab or 4th tab opens. Just out of curiosity, why go to all the trouble to code this "problem" when the same thing can be accomplished with one mouse click?

The Missinglinq

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top