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

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?
 
L

Linq Adams via AccessMonster.com

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
 
G

George Nicholson

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.
 
S

Song Su

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.
 
G

George Nicholson

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top