Results 1 to 5 of 5
  1. #1
    enilc is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    14

    Focus within Tabctl

    My main form has several subforms. It also has a tabctl set of 5 tabs, each with multiple subforms.



    When a use selects one of the tabs in the tbctl, the focus is jumping to a recently added subform, near the bottom and they have to scroll back up to the top of the tabctl. I've been messing with all of the 'tab index' properties, and they seem correct. I have the topmost subform set to tab index 0, and the other subforms in order going down the tabctl. Within each subform, the 'tab index' order is set as well, but each subform has a new tab index order.

    I am trying to have the focus set to the topmost control in the topmost subform when the user selects this tab in the tabctl.

    Am I off-base using 'tab index' to make this happen? Should I somehow be doing this programmatically via the onclick property of the tabctl?

    I appreciate any advice.

    Steve

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    yes, tab index is the order the cursor lands/travels
    but I would suggest to only have 1 subform. Then when user clicks the tab ,swap out the source of the subform.
    This saves LOTS of memory. I've had memory errors with > 1 subform.

    Code:
    Private Sub TabCtl_Change()
          
    Select Case TabCtl.Value
       Case 0
          subFrm.RowSource = "fPaymentsSub"
       Case 1
          subFrm.RowSource = "fPurchasesSub"
       Case 2
          subFrm.RowSource = "fInventorySub"
    End Select
    End Sub
    


  3. #3
    enilc is offline Novice
    Windows 10 Office 365
    Join Date
    Sep 2020
    Posts
    14
    Thanks for the response. I'll take a look at using the case statement to resolve.
    To more explicitly state the problem:

    There is a client form that has several subforms. It also has a tabctl.
    The tabctl has 5 tabs: general, retirement, education, estate, investment
    Each of those tabs has 3-5 subforms.
    On the 'retirement' tab is a 'goals' subform, an 'actions' subform, and a 'retirement spending' subform
    When the 'retirement' tab is clicked, the cursor jumps to the 'retirement spending' subform, control tabindex 0
    I want focus to be in the 'goals' subform, control tabindex 0.
    Each of the subforms (goals, actions, spending) have tabindex order set to 0,1,2.
    So, in my mind, selecting the 'Retirement' tab should set focus to subform tabindex 0, control tabindex 0. But it doesn't. It goes to subform tabindex 2, control tabindex 0.

    That is the issue I'm trying to resolve. Trying to setfocus to subform 0, control 0 when the tabctl is selected.

    I'm going to take a stab at using a version of the code you provided.

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    you can tell it to go directly to the object:
    forms!masterform.subform.form.txtBox1.setfocus

  5. #5
    davegri's Avatar
    davegri is online now Excess Access
    Windows 10 Access 2016
    Join Date
    May 2012
    Location
    Denver
    Posts
    3,407
    See if this will work for you. Make sure you are setting properties for the Subform/Subreport control, NOT the subform itself.

    Click image for larger version. 

Name:	goals.png 
Views:	11 
Size:	36.4 KB 
ID:	44068

    And for the others

    Click image for larger version. 

Name:	Actions.png 
Views:	11 
Size:	37.8 KB 
ID:	44069

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 3
    Last Post: 10-23-2020, 07:13 AM
  2. Replies: 16
    Last Post: 01-06-2015, 09:57 AM
  3. Replies: 6
    Last Post: 05-07-2013, 02:43 AM
  4. Focus on Key Control
    By windwardmi in forum Access
    Replies: 1
    Last Post: 09-07-2011, 04:57 PM
  5. Will not set focus
    By AKQTS in forum Programming
    Replies: 4
    Last Post: 05-04-2011, 06:38 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums