By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,492 Members | 3,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,492 IT Pros & Developers. It's quick & easy.

How to setfocus on a tab in a subform that sits on parent tab?

100+
P: 176
TabCtrl ---
..............Tab1--Subform1
..............Tab2--Subform2---TabCtrl2---Tab21
.................................................. ........---Tab22
.................................................. ........---Tab23
..............Tab3--Subofrm3

I need to setfocus on Tab22
I've tryed - me.Tab2.Tab22.setfocus and me.Tab2.Subform2.Tab22.setfocus
and me.Tab2.Subform2.Form.Tab22.setfocus with no success.

Help will be apritiated.
Feb 11 '07 #1
Share this Question
Share on Google+
12 Replies


MMcCarthy
Expert Mod 10K+
P: 14,534
TabCtrl ---
..............Tab1--Subform1
..............Tab2--Subform2---TabCtrl2---Tab21
.................................................. ........---Tab22
.................................................. ........---Tab23
..............Tab3--Subofrm3

I need to setfocus on Tab22
I've tryed - me.Tab2.Tab22.setfocus and me.Tab2.Subform2.Tab22.setfocus
and me.Tab2.Subform2.Form.Tab22.setfocus with no success.

Help will be apritiated.
Michael,

If you are talking about a multi page layout here then you will find that it is the page that gets focus not the tab.

Mary
Feb 11 '07 #2

100+
P: 176
Michael,

If you are talking about a multi page layout here then you will find that it is the page that gets focus not the tab.

Mary
Mary,

I don't understand what do you mean by 'multy page layout'.
To setfocus to a mysubform which sits on Tab1 of TabCtrl, I compose - me.Tab1.setfocus. Here I want to setfocus to a mysubform which sits on Tab22 of TabCtrl2, while TabCtrl2 being a control of subform2 which subsequently sits on Tab2 of TabCtrl.
Feb 11 '07 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
Mary,

I don't understand what do you mean by 'multy page layout'.
To setfocus to a mysubform which sits on Tab1 of TabCtrl, I compose - me.Tab1.setfocus. Here I want to setfocus to a mysubform which sits on Tab22 of TabCtrl2, while TabCtrl2 being a control of subform2 which subsequently sits on Tab2 of TabCtrl.
I don't know what you mean by Tab1 of TabCtrl. I assumed you were using a multi page object which looks like grey rectangle with tabs accross the top.

Mary
Feb 11 '07 #4

100+
P: 176
I don't know what you mean by Tab1 of TabCtrl. I assumed you were using a multi page object which looks like grey rectangle with tabs accross the top.

Mary

Perhaps I should use the word 'Page' instead of 'Tab'. Do we refer to the same thing? (I think so)
What I'm using is a mainform with TabCtrl control with the pages Page1, Page2, Page3. Page2 has a Subform2 in it, which has TabCtrl2 in it, which has Page21, Page22 in it. I want to set focus on Page22 from mainform, and I don't know how to compose the syntax of this command correctly.

Regards.
Feb 11 '07 #5

MMcCarthy
Expert Mod 10K+
P: 14,534
Perhaps I should use the word 'Page' instead of 'Tab'. Do we refer to the same thing? (I think so)
What I'm using is a mainform with TabCtrl control with the pages Page1, Page2, Page3. Page2 has a Subform2 in it, which has TabCtrl2 in it, which has Page21, Page22 in it. I want to set focus on Page22 from mainform, and I don't know how to compose the syntax of this command correctly.

Regards.
Try ...

Expand|Select|Wrap|Line Numbers
  1. Me.Subform2.Page22.SetFocus
just one thing. Make sure that Subform2 is the name of the subform object and not just the name of the form the subform is based on. To do this go to the properties of the subform object and in the Other tab see what is entered in the Name property.

Mary
Feb 11 '07 #6

nico5038
Expert 2.5K+
P: 3,072
You don't use a reference to the tabcontrol when referring to the objects on a tab.
You can use for the subform2 e.g.:
Me.subform2.form.fieldname
and you'll get the value of the field on the subform.

When you have a sub sub form you use:
Me.subform2.form.subsubform1.form.fieldname
Tab's don't "count". :-)

Nic;o)
Feb 11 '07 #7

100+
P: 176
Try ...

Expand|Select|Wrap|Line Numbers
  1. Me.Subform2.Page22.SetFocus
just one thing. Make sure that Subform2 is the name of the subform object and not just the name of the form the subform is based on.
I understand what do you mean, yes, that is the name of the subform control. (I'm not expertized enogh in programming to fully understand what's an object, for now I realise it's something made of propreties and events) Concerning the command you gave me, it doesn't work. (Method or data member not found error)
Feb 11 '07 #8

MMcCarthy
Expert Mod 10K+
P: 14,534
I understand what do you mean, yes, that is the name of the subform control. (I'm not expertized enogh in programming to fully understand what's an object, for now I realise it's something made of propreties and events) Concerning the command you gave me, it doesn't work. (Method or data member not found error)
Where are you putting this command?
Feb 11 '07 #9

100+
P: 176
Where are you putting this command?
In the main form On Open event.
Feb 11 '07 #10

ADezii
Expert 5K+
P: 8,638
Perhaps I should use the word 'Page' instead of 'Tab'. Do we refer to the same thing? (I think so)
What I'm using is a mainform with TabCtrl control with the pages Page1, Page2, Page3. Page2 has a Subform2 in it, which has TabCtrl2 in it, which has Page21, Page22 in it. I want to set focus on Page22 from mainform, and I don't know how to compose the syntax of this command correctly.

Regards.
You cannot set Focus to Page22 on a Tab Control on a Sub-Form contained within a Page on a Tab Control on the Main Form unless that specifc Page is active. You can set the Focus to Page 22 on TabCtrl2 but unless Page2 on the Parent Tab is visible, you will never see it. What you need is a 2 step process:
Expand|Select|Wrap|Line Numbers
  1. 'First, set the Focus to SubForm2 residing on Page 2 of the Tab 
  2. Control on the Main Form. Forget Page 2 and the Main Tab Control, 
  3. they are irrelevant.
  4. Forms!frmYourMainForm![SubForm2].SetFocus
  5.  
  6. 'Set the specifc Value for Page22 which can be obtained via the Value 
  7. Property of the Tab Control in the OnChange() Event.
  8. Forms!frmYourMainForm![SubForm2].Form![TabCtrl2].Value = XX
  9.  
  10. NOTE: This can all be done from the Main Form.
Feb 12 '07 #11

100+
P: 176
You cannot set Focus to Page22 on a Tab Control on a Sub-Form contained within a Page on a Tab Control on the Main Form unless that specifc Page is active. You can set the Focus to Page 22 on TabCtrl2 but unless Page2 on the Parent Tab is visible, you will never see it. What you need is a 2 step process:
Expand|Select|Wrap|Line Numbers
  1. 'First, set the Focus to SubForm2 residing on Page 2 of the Tab 
  2. Control on the Main Form. Forget Page 2 and the Main Tab Control, 
  3. they are irrelevant.
  4. Forms!frmYourMainForm![SubForm2].SetFocus
  5.  
  6. 'Set the specifc Value for Page22 which can be obtained via the Value 
  7. Property of the Tab Control in the OnChange() Event.
  8. Forms!frmYourMainForm![SubForm2].Form![TabCtrl2].Value = XX
  9.  
  10. NOTE: This can all be done from the Main Form.
ADezii, though I didn't understand what exactly you suggested me to do with the specific value of Tab Control on OnChange event, I did manage to preform the task of opening Page22 with the help of your advice by first "opening the road" for Page2, and then using Subform2 On Open event to further open Page22. It works great!
Thanks :)
Feb 12 '07 #12

ADezii
Expert 5K+
P: 8,638
ADezii, though I didn't understand what exactly you suggested me to do with the specific value of Tab Control on OnChange event, I did manage to preform the task of opening Page22 with the help of your advice by first "opening the road" for Page2, and then using Subform2 On Open event to further open Page22. It works great!
Thanks :)
Sorry for the confusion. As far as the Value Property, if you place Debug.Print Me![TabControlName].Value in the On Change() Event of a Tab Control it will return the value associated with the specifc Page you clicked on. Knowing that value, you can now assign it to the Tab Control (Me![TabControlName].Value = XX) to go to any Page. In any event, I'm glad to be of assistance.
Feb 12 '07 #13

Post your reply

Sign in to post your reply or Sign up for a free account.