Results 1 to 5 of 5
  1. #1
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Event when tab is clicked (2003)

    I have a form which has 5 tab controls. I need some code to run when a particular one of them is clicked but I can't find how to do it.
    I tried setting the On Click event at tab level, but it doesn't trigger until the cursor is clicked somewhere on the tab; even when the tab is active, clicking on the tab control doesn't trigger the event.
    What event do I use (and how) to enable this code to run only when the tab control is clicked/tab becomes active?
    Thanks
    Silverback

  2. #2
    Gold Lounger
    Join Date
    Jun 2001
    Location
    Crystal Beach, FL, Florida, USA
    Posts
    3,436
    Thanks
    1
    Thanked 34 Times in 34 Posts

    Re: Event when tab is clicked (2003)

    You put the code in the tab control's OnChange event. You can test against the .Value property of the tab control to find out which page is selected.
    Mark Liquorman
    See my website for Tips & Downloads and for my Liquorman Utilities.

  3. #3
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Event when tab is clicked (2003)

    Sorry, Mark
    That's gone right over my head. When I click on the tab control and choose Properties | Events, all I'm offered is On Click, On Double Click, On Mouse Down, On Mouse Move and On Mouse Up.
    I tried form level events and couldn't see it there, either. Where do I find the On Change event, please?
    Thanks
    Silverback

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Event when tab is clicked (2003)

    You must either select the tab control in the Controls dropdown on the toolbar or in the upper left corner of the Properties window, or click on an empty part of the bar at the top of the tab control. If you click on a tab, you'll get the events for that tab page, not for the tab control as a whole.

    One more thing: the Value property of the tab control is zero-based, i.e. 0 corresponds to the first tab, 1 to the second tab etc.

  5. #5
    5 Star Lounger
    Join Date
    Jan 2001
    Location
    Warrington, Cheshire, England
    Posts
    712
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Event when tab is clicked (2003)

    Thank you, Hans and Mark <img src=/S/thankyou.gif border=0 alt=thankyou width=40 height=15>
    All working now. The 'On Change' event is somewhat hidden away, though, isn't it?
    I tried to find it in Access help but drew a blank which is why I had to post my second plea for help.
    Anyway, success, thanks to the lounge, as usual.
    Silverback

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •