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

SetFocus on Tab Controls

P: 161
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
Apr 11 '19 #1
Share this Question
Share on Google+
6 Replies

P: 161
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

P: 161
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

Expert Mod 2.5K+
P: 3,284

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

P: 161
Will the afterupdate() respond when the control button has tab pressed on it?
Apr 12 '19 #5

Expert Mod 2.5K+
P: 3,284
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

Expert Mod 15k+
P: 31,494
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

Post your reply

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