473,406 Members | 2,369 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,406 software developers and data experts.

SetFocus on Tab Controls

174 128KB
I'm having difficulty with my tab control. A) Its difficult to switch to the correct tab by clicking it as it might take several attempts so I added
Expand|Select|Wrap|Line Numbers
  1. Private Sub tabPlantReport_Change()
. B) When the button cmdGoToFuel is entered (Its the last tab position to send the tab control to the next page tabFuel) it goes to tabPG, however if I remove the vba for cmdGoToPG then it works.I cant seem to figure it out. C) As I stated I added
Expand|Select|Wrap|Line Numbers
  1. Private Sub tabPlantReport_Change()
which helped clicking tabs but it also errors if I use my nav buttons, always errors on last case.

Expand|Select|Wrap|Line Numbers
  1. 'Form Tab Navigation
  2. Private Sub tabPlantReport_Change()
  3.   Select Case tabPlantReport
  4.     Case 0
  5.       cmdGotoFuel.SetFocus
  6.     Case 1
  7.       cmdGoToPG.SetFocus
  8.     Case 2
  9.       cmdGoToLime.SetFocus
  10.     Case 3
  11.       cmdGoToAggregate.SetFocus
  12.   End Select
  13. End Sub
  14. Private Sub cmdGoToFuel_Enter()
  15. Me![tabFuel].SetFocus
  16. End Sub
  17. Private Sub cmdGoToPG_Enter()
  18. Me![tabPG].SetFocus
  19. End Sub
  20. Private Sub cmdGoToLime_Enter()
  21. Me![tabLime].SetFocus
  22. End Sub
  23. Private Sub cmdGoToAggregate_Enter()
  24. Me![tabAggregate].SetFocus
  25. End Sub
  26.  
Apr 11 '19 #1
6 3764
williamson1979
174 128KB
I also tried this as well and removing all previous posted code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdGoToFuel_Enter()
  2.   tabPlantReport.Value = (tabPlantReport.Value + 1) Mod tabPlantReport.Pages.Count
  3. End Sub
  4. Private Sub cmdGoToPG_Enter()
  5.   tabPlantReport.Value = (tabPlantReport.Value + 1) Mod tabPlantReport.Pages.Count
  6. End Sub
Once I add cmdGoToPG the same thing happens, it skips over tabFuel. I believe I must have a issue with 1 of those 2 tabs but what it could be has me lost. Any ideas?
Apr 11 '19 #2
williamson1979
174 128KB
OK so after I figured out it was a issue with one of those tabs I looked at everything. It was definitely just that. Id added a unbound txtbox that had changed my controls tab order setting the cmdButton to go to tabPG at 0.

With that said since Ive already posted my code which set is the best to use for navigating tabControl?
Apr 11 '19 #3
twinnyfo
3,653 Expert Mod 2GB
Neither.

If you want to go to the next page in your tab control, do this:

Expand|Select|Wrap|Line Numbers
  1. Private Sub NameOfLastControlOnPage_AfterUpdate()
  2.     Me.NameOfNextPage.SetFocus
  3. End Sub
Make things simpler, not more difficult.
Apr 12 '19 #4
williamson1979
174 128KB
Will the afterupdate() respond when the control button has tab pressed on it?
Apr 12 '19 #5
twinnyfo
3,653 Expert Mod 2GB
I have no idea what you mean by "when the control button has tab pressed on it". However, if you have a text box, which is the last text box on a page of your Tab Control and you want to move to the next page of the tab control after you have updated a value in that text box, replace NameOfLastControlOnPage with the actual name of the control and NameOfNextPage with the actual name of the next page in the Tab Control.

If you have a command button that moves to the next page, then just use the same .SetFocus method, but assign it to the command button's OnClick event.

Just think about what you want to happen and when you want that to happen and work through the steps to accomplish those tasks/events.
Apr 12 '19 #6
NeoPa
32,556 Expert Mod 16PB
This has gone messy again Williamson. It starts with two questions. It's obviously going to get messy. Many experts see that and immediately decide not to waste their time on it. Please ensure only one question is asked per thread.
Apr 13 '19 #7

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

Similar topics

3
by: DBQueen | last post by:
I have a form with lines of controls. On some of the lines there are 3 controls (call them A,B,C); other lines have only control A. The controls have been numbered sequentially (Q20, Q21....Q76)...
0
by: Miquel | last post by:
Hi all. I felt frustrated when developing an 'UserControl' derivated from textBox, because sequence event (and Validate event) seems to fail. I Always thought my code was wrong. But after...
4
by: PK9 | last post by:
I have a button at the top of my page that I have an onClick event handler for which makes some new controls (at the bottom of my page) visible. When the user clicks the button I make the new...
8
by: copyco | last post by:
I want to be able to test if my app's form has focus, (ie: not in background, behind other windows). How can I do this? I tried the Me.Focused, but that doesn't work. I think it's because a...
8
by: dominique | last post by:
Hi, Is it possible (in vb.net with WinForms) to loop throw controls inside a container (form or panel) sorting the controls on a property (.tabindex for example) ? My problem : on several...
6
by: =?Utf-8?B?U2NvdHQgTGFt?= | last post by:
Hi, I have a VB.NET form with a bunch of controls in it . The focus is in one of the controls , (i.e. a textbox), is there any way to click on the form itself and make the textbox lose focus and...
4
by: Rafael A. M. Borges | last post by:
Hi, How can I set the focus on the first control in the page? I tried Page.Controls(0).Focus() but it didn't works. Does anyone knows it?
5
by: Matt B | last post by:
I know this is a bit of nonstandard behavior, but I would like the Enter key to move focus through a group of radiobuttons without selecting them. The user would then have to use Space or actually...
0
by: ag46677 | last post by:
Hi All, I have a web based application and i want to have focus on a text box on click of a button i have been trying the below solution but unfortunately its working in my test application but...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
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.