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 Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

working with a tab control on a form

Status
Not open for further replies.

dfwelch

Programmer
Dec 5, 2003
51
US
I am not sure if this can be done, but I'll toss it out there as a question anyhow.

I have a tab control on my form that contains four tabs. In my database, this form will be opened from two different forms. I would like to have the tab that is first active on the form be the second tab when it is opened from one form, and the first tab when it is opened from the other form. What I am looking for is a property like ActivePage that specifies which tab in the control is the first one to show, by default it is obviously the leftmost tab.

Alternatively, I would settle for just have the second tab from the left be the one that comes active first when the form opens.
 
Add the following to the On Click event of the button that opens the form:

Private Sub cmdButton1_Click()

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "NameofFormOpening"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Forms.NameofFormOpening.Tab1Name.SetFocus

End Sub

Repeat this for the other button, only change the Tab1Name to Tab2Name.


HTH



"I know what you're t'inkin', ma petite. Dat Gambit... still de suave one, no?"
 
Hi

Use .OPenArgs to pass id of the openning form to the openned form, in the openned form onopne event set the value of the table control, something like

In the openning form:

DoCmd.OpenForm "FrmMyForm",..etc,"Form1"

in frmMyForm

If me.openargs = "Form1" Then
myTabCtl.Value = 0
Else
myTabCtl.Value = 2
End If

Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
A different take on what KenReay said

For the first form
Code:
myTabName.pages.Item(0).PageIndex = 1

For the second form
Code:
myTabName.pages.Item(1).PageIndex = 0

This will move the page to the first or second position on the tab control.

Of course there is a little bit more code you need to write but this is the simplest way to do it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top