Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Jun 2002
    Location
    Nottingham, Nottinghamshire, United Kingdom
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Tab Control (Access 2K)

    I have a form with a tab control on it and a cancel button to the side. When the form opens only the first tab is visible and I collect some transactional information such as entry date before making the other tabs visible. The code for this is:

    Me!tabCharge.Visible = True
    DoCmd.GotoControl "tabCharge" ' to bring that tab to the front then
    DoCmd.GotoControl "btnCancel" ' to move the focus onto the Cancel button.

    The last line fails but I don't understand why. I need to move the focus after making the tab visible as otherwise it goes to one of the fields on the tab and exiting from that field causes the checking code attached to it to fail.

    Does anyone know how to make a tab visible and to the front without moving the focus to it?

    David Parton

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

    Re: Tab Control (Access 2K)

    I assume that tabCharge is the name of one of the pages of the tab control. I don't know what the name of the tab control itself is. You might try code like this:

    tabCharge.Visible = True
    tabControlName.Value = 2 ' Zero-based index of tab to activate
    btnCancel.SetFocus

    Replace tabControlName by the name of your tab control. The Value of a tab control is the zero-based index of the active tab, so the first tab has index 0, the second has index 1 etc. The above example would activate the third tab.

  3. #3
    3 Star Lounger
    Join Date
    Jun 2002
    Location
    Nottingham, Nottinghamshire, United Kingdom
    Posts
    257
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Tab Control (Access 2K)

    Many thanks Hans. Works fine.

Posting Permissions

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