Results 1 to 5 of 5
  1. #1
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451

    tab control visible

    i have a form with a tab control. one of my tabs i have invisible using the form load event until a command button is used then the tab becomes visible and sets focus. what i am after is that when the user leaves the tab and moves to another tab the special tab visibility goes to false again. i would have thought that using the click event of the other three tabs and setting the visibility of the special tab to false would work but so far i can't get it. does anyone have any experience with hiding tabs on a tab control? using


    Code:
    Me.TabCtl62.Pages("add craft").Visible = False
    which works for the load event but not the tab click. thought maybe since i have focus on the "add craft" that maybe that was holding me up but i have tried setting focus to other objects first and still no luck. ideals????

  2. #2
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    The tab control is a strange animal. Clicking on the tab where the caption is does not initiate any events. You have to click in the body of the selected tab to have an event (say the click event) fire.

    I did find a write up from FMS about tab controls:
    https://www.fmsinc.com/microsoftacce...abs/index.html


    Another method might be a "roll your own" tab control. Disadvantage is you have to write a lot of code. The advantage is that you have full control and can even color the tabs.
    http://www.fontstuff.com/access/acctut12.htm


    Both sites have example databases.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Here’s a short tutorial I post when this question comes up:

    The first thing to understand is that Tabbed Page Index is Zero-based, i.e. the first page has a value of 0, the second page has a value of 1, the third page has a value of 2, etc.

    Secondly, you need to understand that the OnClick event of a Tabbed Page only fires when you click on the page itself, not the tab at the top of the page!

    Lastly, you need to understand that the Tabbed Control change event fires anytime the Tabbed Pages change. But to base something on the change event, you have to identify the particular page that has focus.


    Code:
    Private Sub YourTabbedControlName_Change()
      Select Case YourTabbedControlName 
        Case 0  'First Page 
          'Code for Page 1 goes here
        Case 1  'Second page 
          'Code for Page 2 goes here
        Case 2   'Third page
          'Code for Page 3 goes here
      End Select
    End Sub

    So, basically, place the code you posted under each Case except the the one that is appearing/disappearing.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Micron is offline Virtually Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,737
    You can get real fancy like one of the posted links, or something less - which is what I threw together. The control style is set to none (no tab, no button) and a label (which you can colour) takes place of the tab and receives the click event. It takes 4 lines of code to switch back and forth for each label, which I guess means 4 more lines for each page also. This doesn't include any code for setting up the form on open. To simplify it further, I suppose a little function can receive two boolean values for my pages 4 and 5; which to hide and which to show, and reverse the visibility of the pieces. Something like Function ShowHide (pge4 as Boolean, pge5 as Boolean) and on label 4 click; ShowHide(False,True). If you don't want to use the page index, use the page name. On this little exercise, I found that I didn't have to write Me.tabCtl3.Pages("Page4"). It seemed to work ok with just Me.Page4.Visible = True or whatever. I also found that the page click event doesn't fire if all the page controls are disabled.

    Another available trick is to use transparent labels over command buttons if you like the look of the button versus a label. One thing you can do with a label that I guess you can't with a button is give it a depressed look (kinda like some people I know!).


    Click image for larger version. 

Name:	pge4.jpg 
Views:	13 
Size:	5.6 KB 
ID:	23577 Click image for larger version. 

Name:	pge5.jpg 
Views:	13 
Size:	5.8 KB 
ID:	23578
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #5
    vicsaccess's Avatar
    vicsaccess is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2015
    Posts
    451
    thanks guys that helps. looks like a few more pages in my onenote file.

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

Similar Threads

  1. Replies: 16
    Last Post: 03-26-2015, 08:35 PM
  2. Replies: 12
    Last Post: 12-11-2012, 09:27 AM
  3. Replies: 13
    Last Post: 05-14-2012, 03:41 AM
  4. Replies: 3
    Last Post: 03-29-2012, 12:40 PM
  5. Replies: 2
    Last Post: 01-06-2011, 04: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