If you just want to have the "tabdepts" tab to be selected when form2 opens, then make the "Page Index" property for the "tabdepts" tab to be (0) zero. You may also want to change the "Page Index" property for your other tabs so they will be in the order you would like them to be.
If, on the other hand, you want to be able to specify which tab is displayed when the form open based on some info or data, that will require some coding but is can be done.
In your original post you had only indicated that you were trying to open form 2 (where the tab control is) from form one. That is why I suggested that you could just change the "Page Index" property to force the desired tab to be displayed when form 2 opened.
Specifying a specific tab to be presented when opened from a form poses a different problem.
First, you will need a way to pass information from the form that is opening form 2 to indicate which form opened form 2. You can do this by using the "OpenArgs" argument of the docmd.openform method. like this:
Code:
DoCmd.OpenForm "Form2",,,,,, "Form1"
This line of code would be in the Click Event of the command button on "Form1". (You would change the "Form1" to any value that would be an indicator that "Form1" is opening "Form2" Obviously, you will need to use this same line of code from a command button on "Form3", passing a value that indicates that "Form3" opened "Form2".
Next, you will need VBA code in the On Open event of "Form2" that will evaluate which form called or opened "Form2". I get the impression that there may be multiple forms that would be calling or opening "Form2" and not just a couple. If this is the case, I would use a "Select Case" to do this type of evaluation. Like this:
Code:
Select Case Me.OpenArgs
'create a "Case" statement for each value that will be
'passed using the "OpenArgs" argument in the "OpenForm" method
Case "Form1"
'Set focus to the tab that you want to display, using the
'Page Index" property of that tab or page
Me.TabCtl0.Pages(0).SetFocus
Case "Form3"
Me.TabCtl0.Pages(2).SetFocus
Case Else
'the "Else" statement can be used here if you have multiple forms
'that you need to display a default tab or page. In this case you
'would not pass any value in the "OpenArgs" argument (just leave
'it blank)
Me.TabCtl0.Pages(1).SetFocus
'you can have as many "Case" statements as you need
End Select
Each tab (page) of a tab control has a unique "Page Index" property.
In the code above you are simply using VBA code to specify the tab or page of the tab control will be displayed (have the focus).