Results 1 to 10 of 10
  1. #1
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Go to a specific page in tab control (Access 2000)

    I have a form containing a tab control and whenever a user uses the Lookup combo box to go to a different record, I would like the focus to return to the first page of my tab control using the after update event of the Lookup combo box. The page index of the tab I want to focus on is 0.

    Using help it looked like the way to accomplish what I wanted was: DoCmd GoToPage 0

    When I tried this in my code I got the following error: "The page number you used as an argument for the GoToPage action or method doesh't exist in this form."

    What am I doing wrong.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  2. #2
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Go to a specific page in tab control (Access 2000)

    Hi Judy,
    GoToPage refers to pages on the form. Try something like:
    Me.TabControl.Pages(0).SetFocus
    Hope that helps.
    Regards,
    Rory

    Microsoft MVP - Excel

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to a specific page in tab control (Access 2000)

    After I gave my tab control a name and replaced the words TabControl in your code with it's name, the code worked like a charm. Thanks so very much.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  4. #4
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Go to a specific page in tab control (Access 2000)

    it suddenly occurred to me that I should have pointed that out, but you beat me to it! Glad to help in the end.
    Regards,
    Rory

    Microsoft MVP - Excel

  5. #5
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to a specific page in tab control (Access 2000)

    Judy,

    In the on current event of the form put
    Me!NameOfPage.SetFocus

    where NameOfPage the name of the first page is from your TabControl.
    You can put another SetFocus after this one if you want the cursor goes to another control in your form in or out the TabControl

    Success

    Francois

    You get your answer while i was searching
    Francois

  6. #6
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to a specific page in tab control (Access 2000)

    One of my tabs contains a subform that also has a tab control that I wanted to have work this same way so that anytime the focus returns to the main tab called Transition, the focus would be on the first tab within the Transition subform. This one is a little harder to get to work. I tried to enter it into the On got focus event for the subform. I don't get an error message, it just doesn't pay any attention to the code.
    Me.tabTrans.Pages(0).SetFocus
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  7. #7
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Go to a specific page in tab control (Access 2000)

    Subforms set the focus automatically to the first control in the tab order, which might be the tab control, but it won't be a particular page. You would have to create additional code to make Page(0) of the tab control on the subform visible.
    Charlotte

  8. #8
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to a specific page in tab control (Access 2000)

    The tab control is the only control on the subform and all the textboxes and fields are located on one of its tabbed pages. What happens is when tab 3 is selected and then you move to one of the other main form's tabbed pages and then come back to the subform the page that was accessed last is the one that is displayed, rather than the first one in the subform's tab control.

    I can not figure out how to attach code to an event that the subform will recognize and how the code that was suggested by Rory that worked so nicely for the tab control on the main form won't seem to work for my subform's tab control.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  9. #9
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    Manassas, Virginia, USA
    Posts
    363
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Go to a specific page in tab control (Access 2000)

    I kept trying different ways of referring to the tab control on the subform and finally found that by placing the following code in the On Enter event of the subform it worked: Forms!MainFormName!SubFormName!TabControlName.Page s(0).SetFocus.

    Thanks again for everyone who took time to respond.
    Judy Jones, Computer Training Specialist
    Manassas, Virginia

  10. #10
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Go to a specific page in tab control (Access 2000)

    No, you need to do it from the main form, using the same event you're using to set the focus to the page on the mainform tab control. For the tab control on the subform, just use something like this:

    Me!MySubform!TabCtl0 = 0

    What this does is set the value of the tab control on the subform to the index number for the first page, and that causes that page to the displayed on top.
    Charlotte

Posting Permissions

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