473,396 Members | 2,030 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Setting the focus on a subform's Tab

Ericks
74
Setting focus is addressed through several questions on this forum but I find this so complicated that I need a taylormade answer.

I have a tabbed main form called "Compounds". On one of the tabs, called "Page75" is a tabbed subform called "RegistrationLaunchTogether" with one of its tabs called "Observations". How do I set the focus on this tab from outside the main form?
Dec 7 '07 #1
14 10676
Rabbit
12,516 Expert Mod 8TB
Setting focus is addressed through several questions on this forum but I find this so complicated that I need a taylormade answer.

I have a tabbed main form called "Compounds". On one of the tabs, called "Page75" is a tabbed subform called "RegistrationLaunchTogether" with one of its tabs called "Observations". How do I set the focus on this tab from outside the main form?
Me.SubformName.Form.TabControlName.Pages("PageName")
Dec 7 '07 #2
Ericks
74
Shouldn't the main form be mentioned also?
Dec 7 '07 #3
ADezii
8,834 Expert 8TB
Setting focus is addressed through several questions on this forum but I find this so complicated that I need a taylormade answer.

I have a tabbed main form called "Compounds". On one of the tabs, called "Page75" is a tabbed subform called "RegistrationLaunchTogether" with one of its tabs called "Observations". How do I set the focus on this tab from outside the main form?
The following code will Set Focus to the RegistrationLaunchTogether SubForm on Page 75 outside the context of the Compounds Form. It assumes the Tab Control on Compounds is named TabControl. This is all I had time for at the moment:
Expand|Select|Wrap|Line Numbers
  1. Forms!Compounds!TabControl.Pages!Page75.Controls!RegistrationLaunchTogether.SetFocus
Dec 7 '07 #4
Ericks
74
The following code will Set Focus to the RegistrationLaunchTogether SubForm on Page 75 outside the context of the Compounds Form. It assumes the Tab Control on Compounds is named TabControl. This is all I had time for at the moment:
Expand|Select|Wrap|Line Numbers
  1. Forms!Compounds!TabControl.Pages!Page75.Controls!RegistrationLaunchTogether.SetFocus

Ok, that I assume will put the focus on the subcontrol. But I need to go one step further, namely to put the focus on the subcontrol's tab called "Observations"
Dec 7 '07 #5
Ericks
74
Ok, that I assume will put the focus on the subcontrol. But I need to go one step further, namely to put the focus on the subcontrol's tab called "Observations"
ADezii, your code worked in that it set focus to the tabbed subform. That's already great. But I need to go as said one step further, to a tab on that subform
So just to put all the objects together:

Mainform: Compounds
Tab control of Mainform: TabCtl16
Tab of Mainform: Page75
Subform: RegistrationLaunchTogether
Tab control of Subform: TabCtl0
Tab of Subform: Observations

So what should I add to your code to set the focus on Observations outside the context of the Compounds Form
Dec 8 '07 #6
ADezii
8,834 Expert 8TB
ADezii, your code worked in that it set focus to the tabbed subform. That's already great. But I need to go as said one step further, to a tab on that subform
So just to put all the objects together:

Mainform: Compounds
Tab control of Mainform: TabCtl16
Tab of Mainform: Page75
Subform: RegistrationLaunchTogether
Tab control of Subform: TabCtl0
Tab of Subform: Observations

So what should I add to your code to set the focus on Observations outside the context of the Compounds Form
It hasn't been tested, but something in the order of:
Expand|Select|Wrap|Line Numbers
  1. Forms!Compounds!TabCtl16.Pages!Page75.Controls!R  egistrationLaunchTogether.Form!TabCtl0.Pages!Observations.SetFocus
  2.  
Dec 8 '07 #7
Ericks
74
It hasn't been tested, but something in the order of:
Expand|Select|Wrap|Line Numbers
  1. Forms!Compounds!TabCtl16.Pages!Page75.Controls!R  egistrationLaunchTogether.Form!TabCtl0.Pages!Observations.SetFocus
  2.  
With this code the main form opens but it doesn't go to tab Page75. It stays on the first Tab. But when I click on tab Page75 the focus on the Subform is on the Observations tab. So I added your first code as second line and now it works. It looks like this:

Forms!Compounds!TabCtl16.Pages!Page75.Controls!Reg istrationLaunchTogether.Form!TabCtl0.Pages!Observa tions.SetFocus
Forms!Compounds!TabCtl16.Pages!Page75.Controls!Reg istrationLaunchTogether.SetFocus
Dec 8 '07 #8
ADezii
8,834 Expert 8TB
With this code the main form opens but it doesn't go to tab Page75. It stays on the first Tab. But when I click on tab Page75 the focus on the Subform is on the Observations tab. So your code did something "behind the scenes" but stayed at the first tab.
Here is a Method that I have tested and it does, in fact, work:
  1. Assign a Hot Key (&O) combination to the Observations Tab (set the Name = &Observations).
  2. The following code will activate that Tab (Observations) on the Sub-Form:
    Expand|Select|Wrap|Line Numbers
    1. Forms!Compounds!TabCtl16.Pages!Page75.Controls!RegistrationLaunchTogether.SetFocus
    2. SendKeys "%O"
    3.  
  3. It is not very elegant, but it does work.
Dec 8 '07 #9
Ericks
74
Here is a Method that I have tested and it does, in fact, work:
  1. Assign a Hot Key (&O) combination to the Observations Tab (set the Name = &Observations).
  2. The following code will activate that Tab on the Sub-Form:
    Expand|Select|Wrap|Line Numbers
    1. Forms!Compounds!TabControl.Pages!Page75.Controls!RegistrationLaunchTogether.SetFocus
    2. SendKeys "%O"
    3.  
  3. It is not very elegant, but it does work.
As written above, this is what I did and now it seems to work:

1. Forms!Compounds!TabCtl16.Pages!Page75.Controls!Reg istrationLaunchTogether.Form!TabCtl0.Pages!Observa tions.SetFocus

2. Forms!Compounds!TabCtl16.Pages!Page75.Controls!Reg istrationLaunchTogether.SetFocus

Important is that it works but I'm curious tio know why it needs the two lines...

So thanks a lot. It worked. Highly appreciated.

Eric
Dec 8 '07 #10
Jim Doherty
897 Expert 512MB
Here is a Method that I have tested and it does, in fact, work:
  1. Assign a Hot Key (&O) combination to the Observations Tab (set the Name = &Observations).
  2. The following code will activate that Tab (Observations) on the Sub-Form:
    Expand|Select|Wrap|Line Numbers
    1. Forms!Compounds!TabCtl16.Pages!Page75.Controls!RegistrationLaunchTogether.SetFocus
    2. SendKeys "%O"
    3.  
  3. It is not very elegant, but it does work.
Hi Dez,

Just offering my two penneth FWIW to the posting (you might want to include a mention to this in the 'howto' article 'referring to tab controls' I've just read on here if you consider it helpful?)

Tab controls form part of a form object so you can refer to them explicitly by name including the pages of a tab....

Me!SubformName!RegistrationLaunchTogether.SetFocus
or
Me!SubformName.form.RegistrationLaunchTogether.Set Focus
or
Me!SubformName.form!RegistrationLaunchTogether.Set Focus

does what the poster requires so drilling down the hierachy through to the controls collection is not actually needed. In addition it also caters for the situation where they 'might' delete a tab page at some point causing the index number to shift. I've seen several postings where they are hard coding the index number in, and of course that can alter things significantly at runtime with the wrong page being selected because there hitherto absolute reference has been broken.

I agree with the poster referring to them is confusing to the newbie

Regards

Jim :)
Dec 8 '07 #11
ADezii
8,834 Expert 8TB
Hi Dez,

Just offering my two penneth FWIW to the posting (you might want to include a mention to this in the 'howto' article 'referring to tab controls' I've just read on here if you consider it helpful?)

Tab controls form part of a form object so you can refer to them explicitly by name including the pages of a tab....

Me!SubformName!RegistrationLaunchTogether.SetFocus
or
Me!SubformName.form.RegistrationLaunchTogether.Set Focus
or
Me!SubformName.form!RegistrationLaunchTogether.Set Focus

does what the poster requires so drilling down the hierachy through to the controls collection is not actually needed. In addition it also caters for the situation where they 'might' delete a tab page at some point causing the index number to shift. I've seen several postings where they are hard coding the index number in, and of course that can alter things significantly at runtime with the wrong page being selected because there hitherto absolute reference has been broken.

I agree with the poster referring to them is confusing to the newbie

Regards

Jim :)
Hell Jim, your two penneth is always welcome and definately appreciated.
Dec 9 '07 #12
Ericks
74
Hell Jim, your two penneth is always welcome and definately appreciated.
whilst this newbie witnesses the discussion in a state of amazed admiration and profound bewilderment exclaiming to the Gods of VBA, not worthy, not worthy...

Great job you guys. I'm glad there is this forum.
Dec 9 '07 #13
ADezii
8,834 Expert 8TB
whilst this newbie witnesses the discussion in a state of amazed admiration and profound bewilderment exclaiming to the Gods of VBA, not worthy, not worthy...

Great job you guys. I'm glad there is this forum.
We are just as glad to have you aboard.
Dec 9 '07 #14
Jim Doherty
897 Expert 512MB
whilst this newbie witnesses the discussion in a state of amazed admiration and profound bewilderment exclaiming to the Gods of VBA, not worthy, not worthy...

Great job you guys. I'm glad there is this forum.
You're very welcome Ericks,

As for profound bewilderment I remember feeling that way once many years ago when I first picked up a mouse pointing it at the monitor expecting to change channels :)

Jim :)
Dec 9 '07 #15

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

Similar topics

3
by: Jesper Dannemamm | last post by:
Hi I am having trouble setting focus on I tried using this script in the usercontrol's page_load sub to set focus on a textbox with the ID = "user_name": Page.RegisterStartupScript("focus",...
20
by: Arne | last post by:
During testing <div style="overflow:auto;"> in CSS I noticed the mousewheel would work in Mozilla only after I made a <a href="#">some text</a> link and clicked on that, within the div. It...
0
by: Shravan | last post by:
Hi, I have a Windows Forms Custom DataGrid, which is put in a usercontrol, which on setting DataSource is setting focus to grid. The call stack for setting the focus is as follows. This is not...
2
by: Mystery Man | last post by:
We have an MDI application that is not setting always setting focus to the newly corrected MDI. It is creating the form and it is the topmost but it does not have focus. The code we are using to...
2
by: Jesper | last post by:
Hi, I'm showing a usercontrol containing a textbox on the screen by clicking a notifyIcon in the taskpane. I use textBox.Focus() to set the focus for the texbox, and I also get a blinking...
3
by: Steve Yerkes | last post by:
There seems to be way too much confusion over how to set focus on the a field using a field validator. I looked all over the web and found people trying to do this, but not getting anywhere. There...
4
by: Wayne Wengert | last post by:
How can I have the focus on a specific textbox when a page opens? In the old ASP pages I could use an onload directive in the <Body> element but that does not work on my aspx pages? Wayne
12
by: CLEAR-RCIC | last post by:
Hi, I'm having problems setting focus to a textbox on a web user contol on an asp.net web page. The following script works on normal asp.net pages: <script language="javascript"> function...
3
by: register_allocation | last post by:
I have a frameset where I call a JavaScript function in the onLoad method: .... <frameset cols="..." onLoad="setFn()"> ... <frame name="data_frame" ...> </frameset> In setFn, I am...
3
by: kelvin.koogan | last post by:
I have a number of controls on a tab page. I want to validate them all when the user tries to leave the tab. I then want to highlight the first control which fails validation. How can I do this? I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.