By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,380 Members | 3,074 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,380 IT Pros & Developers. It's quick & easy.

How to make the tab control to open on a specific page?

100+
P: 176
When I open form2 I would like the tab control to be opened on a specific tab page, depending on the preferences of form1.

Is it possible to do?
Cheers.
Dec 25 '06 #1
Share this Question
Share on Google+
2 Replies


missinglinq
Expert 2.5K+
P: 3,532
Almost anything is possible! Here's some sample code, where the form to be opened is 2ndForm and the tabbed page to be displayed on open of 2ndForm is named ThirdPage. The final argument of the OpenForm command is called openargs, and you assign a value to it in the calling form, then check for its value in the FormLoad event of the called form
and do something (open a tabbed page isn this case) accordingly.

Expand|Select|Wrap|Line Numbers
  1. 'On the first form 
  2. Private Sub GotoTabbedPage_Click()
  3. Dim strPageToOpen as String    
  4.    strPageToOpen = "ThirdPage" 
  5.    DoCmd.OpenForm "2ndForm", , , , , , strPageToOpen
  6. End Sub
  7.  
  8. 'On the second form
  9. Private Sub Form_Load()
  10.     If OpenArgs = "ThirdPage" Then
  11.       ThirdPage.SetFocus
  12.     End If
  13. End Sub
In your code in the first form you need to set the variable strPageToOpen equal to the preference from your first form, however you determine that, then in the second form, include in the If...End If construct all possible choices for pages to open. If you have many of these you might want to replace the If...End If construct with Select Case.
Dec 25 '06 #2

ADezii
Expert 5K+
P: 8,638
When I open form2 I would like the tab control to be opened on a specific tab page, depending on the preferences of form1.

Is it possible to do?
Cheers.
'Another option would be to use the Value Property of the Tabbed Dialog
'Control. In the Open() Event of the 2nd Form:

Expand|Select|Wrap|Line Numbers
  1. Select Case Me.Openargs
  2.     Case "FirstPage"
  3.         Me!TabCtl62.Value = 0
  4.     Case "SecondPage"
  5.         Me!TabCtl62.Value = 1
  6.     Case "ThirdPage"
  7.         Me!TabCtl62.Value = 2
  8.     Case "You get the idea"
  9. End Select
NOTE: Individual Pages are indexed starting at 0, thus the offset
Dec 26 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.