Open the form with 2nd tab focused instead of 1st tab

  • Thread starter Thread starter Song Su
  • Start date Start date
S

Song Su

Access 2003

I have a button on a form to open another form with 2 tabs.

What's the code to open a form with 2nd tab focused instead of default 1st
tab?
 
Try this: In the Form_Load event of the second form, set focus to a control
that resides on the second tabbed page. If the control is named YourControl,
use

Private Sub Form_Load()
YourControl.SetFocus
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000/2003

Message posted via AccessMonster.com
 
In Form_Open:
Me.MyTabControl = 1

Where 1 is the PageIndex value of the tab you want pre-selected. Note that
the PageIndex of the 1st page is 0, so 1 represents the 2nd page.
 
Thanks for quick reply. Let me make more clear:

My form1 as 2 buttons. Button1 open form2 first tab (default). I want Button
2 open form2 2nd tab. If I use form_load as suggested, my 1st button on
form1 would not focus 1st tab of form2.
 
Two approaches. Either:

1) Use the OpenArgs argument of OpenReport to send a value that FormOpen or
Form_Load can use:
Button1_Click: DoCmd.OpenReport "myFormWithTabs",,,,,,'0'
Button2_Click: DoCmd.OpenReport "myFormWithTabs",,,,,,'1'

Form_Open: Me.MyTabControl = Cint(nz(Me.OpenArgs,'0')

or

2) Open the form and set the tab from Button2_Click:
DoCmd.OpenReport "myFormWithTabs"
Forms("myFormWithTabs").MyTabControl = 1

All the above is aircode.
 
Back
Top