ACC2000: Tab Control Inserted on Another Tab Control Remains on Top

ID: Q208808


The information in this article applies to:


SYMPTOMS

Novice: Requires knowledge of the user interface on single-user computers.

When you place a tab control on any page of another tab control, and then view the form in Form view, the embedded tab control is visible from any page of the main tab control.


CAUSE

Tab controls can not be nested.


RESOLUTION

You need to use Visual Basic for Applications code to set the Visible property of the tab control that you want to appear to be "nested" within another tab control.

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support professionals can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact a Microsoft Certified Solution Provider or the Microsoft fee-based consulting line at (800) 936-5200. For more information about Microsoft Certified Solution Providers, please see the following page on the World Wide Web:

http://www.microsoft.com/mcsp/
For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

http://www.microsoft.com/support/supportnet/overview/overview.asp
  1. Follow steps 1 through 10 in the "Steps to Reproduce Behavior" section later in this article.


  2. Open the form in Design view.


  3. In the Object list (the drop-down list on the far left of the Formatting toolbar), click TabControlMain.


  4. Right-click TabControlMain, and then click Properties.


  5. Click the Event tab, and then click the OnChange property box.


  6. Click the Build button (...) to the right of the OnChange property box.


  7. In the Choose Builder dialog box, click Code Builder, and then click OK. This opens the Visual Basic Editor.


  8. Set the OnChange property to the following event procedure:


  9. 
    Private Sub TabControlMain_Change()
       If TabControlMain.Value = 1 Then
          TabControlEmbedded.Visible = True
       Else
          TabControlEmbedded.Visible = False
       End If
    End Sub 
  10. To return to the form, on the View menu, click Microsoft Access.


  11. On the View menu, click Form View.


  12. Click Page 1 of TabControlMain, and then click Page 2. Note that TabControlEmbedded is visible only on Page 2.


NOTE: The Value property of a tab control contains the index number of the current Page object. There is one Page object for each tab in a tab control. The first Page object always has an index number of 0, the second has an index number of 1, and so on.


MORE INFORMATION

Form controls cannot be placed inside other form controls. The only exception to this is the Subform/Subreport control, which can contain a form that has additional controls. Even when you place a tab control on top of another tab control, they are both associated with the form, not with each other.

You can demonstrate this by using the form you design in the "Steps to Reproduce Behavior" section later in this article. Once the form is showing in form view, open the Immediate Window by typing CTRL+G and type each of the following statements followed by the ENTER key.

?Forms!Form1!TabControlMain.Parent.Name
?Forms!Form1!TabControlEmbedded.Parent.Name
You will see that the Parent for each of the tab controls is the form itself, not the other tab control.

Steps to Reproduce Behavior


  1. Start Microsoft Access and open any database.


  2. In the Database window, click Forms under Objects, and then click New.


  3. In the New Form dialog box, click Design view, and then click OK to create a form not based on any table or query.


  4. On the View menu, click Toolbox if the toolbox is not already visible; click the Tab Control button on the Toolbox toolbar, and then create a tab control in the detail section of the form.


  5. On the View menu, click Properties; set the control's Name property to TabControlMain.


  6. Click Page 2 of TabControlMain.


  7. Create another tab control on Page 2 of TabControlMain.


  8. On the View menu, click Properties; set the Name property of the tab control to TabControlEmbedded.


  9. On the View menu, click Form View.


  10. Click Page 1 of TabControlMain, and then click Page 2. Note that TabControlEmbedded is visible on both pages.



REFERENCES

For more information about the tab control, click Microsoft Access Help on the Help menu, type "tab control" in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

For more information about the Parent property, click Microsoft Access Help on the Help menu, type "parent property" in the Office Assistant or the Answer Wizard, and then click Search to view the topics returned.

Additional query words: prb multiple pages


Keywords          : IntpCstm 
Version           : WINDOWS:2000
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: July 6, 1999