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

Open a form on a specific page tab 1

Status
Not open for further replies.

Hfnet

IS-IT--Management
Dec 31, 2003
369
GB
I have a form (Use) with a two tab control subform. I have two command buttons on a main form (main), and I want one button to open the new form with Tab Page 0 in the front, and the other button to open the same form but with Tab Page 1 in focus.

Can anyone help?

Thanks
 
There may be another way to do this but this is how I would tackle it...

With each button set up a OpenArgs value to pass through to the subform.

Code:
Private Sub Command1_Click()
Dim stOpenArgs as String
Dim stDocName as String
Dim stLinkCriteria as String

     stOpenArgs = "0" [COLOR=green] 'for Tab1 [/color]
     stDocName = "subFormName" [COLOR=green] 'name of subform [/color]
     DoCmd.OpenForm stDocName, , , stLinkCriteria, , , stOpenArgs

End Sub

Private Sub Command2_Click()
Dim stOpenArgs as String
Dim stDocName as String
Dim stLinkCriteria as String

     stOpenArgs = "1" [COLOR=green] 'for Tab2 [/color]
     stDocName = "subFormName"  [COLOR=green]'name of subform[/color]
     DoCmd.OpenForm stDocName, , , stLinkCriteria, , , stOpenArgs

End Sub
Then in the subform "On Load" event include the code...
Code:
Private Sub Form_Load()

    Me.TabCtl = Me.Form.OpenArgs [COLOR=green]'where TabCtl is the name of your Tab Control[/color]

End Sub

Hope this helps. Good Luck!

 
Thanks, worked a treat
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top