change focus on tab control

jeo

Registered User.
Local time
Today, 22:53
Joined
Dec 26, 2002
Messages
299
i have a form with 2 tabs and a sub form on each of those tabs.
form1, subformA, subformB on tab control - tabctrl - pageA, pageB.
how can i set focus from one tab to another without actually clicking the tab?
i tried this:
TabCtl.Pages("page2").SetFocus
it's comming up with an error - "object required"
i also tried
page.2.setfocus and that's comming up with an error that it's wrong syntax.
i also tried
formMyForm.page2.setfocus and that says object required as well.
so i know i'm not doing something right.
any suggestions?
thanks.
 
Play with this syntax...... I have one and on the OnOpen event of the form with two tabs I can use.......

Me.Page2.setfocus

"Page2" being the name of my second tab

That should be all it takes
 
this does work for On-Open event on my main form to set focus to that tab.
i need to update something to tabA in subformA and i was trying to do that setfocus event on after-update on subformA and setfocus to tabB.
when i do that it produces an error saying Methor or Data Memeber not found for that line of code:
Me.Page2.setfocus
where it works good for the on-open event.
any way i can do that for after-update even on subformA to setfocus to tabB?
thank you.
 
Are you trying to set focus on the tab, or change tabs??

To change tabs you use:

me.TabCtl = 1

Where 1 is the tab index you want to select, and TabCtl is the name of your tab control.
 
i guess you are right, i'm trying to change from one tab to another.
i tried what you suggested, but again, it's saying the same thing
Methor or Data Memeber not found
i'm guess it's because i'm in subformA, trying to update something and then trying to perform that line of code on after-update even in subformA.
may be i need to set focus back on the main form out of the subform and then change tabs?
 
if your tab is called PageA then you need to refer to it by that name, if your overall tabcontrol is called tabctl then thats what you use

hence tabctl.pages("PageA").setfocus, not ("page1")

or you can use tabctl.pages(1).setfocus, providing you are sure of the oridnal number of pages. Better to use the name reference in case you change the page order or add new pages later.

You are probably mixing up the 2 concepts
 
that made sence, thank you.
i tried it and it got me out of the method or data object not found error, but now it's producing "Object Required" error.
this is what i used:
TabCtl.Pages("PageA").SetFocus
What am I doing wrong?
 

Users who are viewing this thread

Back
Top Bottom