Microsoft KB Archive/166844

= ACC97: Removing All Pages from Tab Control Removes the Control =

Article ID: 166844

Article Last Modified on 1/19/2007

-

APPLIES TO


 * Microsoft Access 97 Standard Edition

-



This article was previously published under Q166844



Moderate: Requires basic macro, coding, and interoperability skills.



SYMPTOMS
When you modify a Tab control in Microsoft Access 97, either manually or with Visual Basic for Applications code, if you delete the last page of the Tab control, the control itself is also removed from the form.

This article assumes that you are familiar with Visual Basic for Applications and with creating Microsoft Access applications using the programming tools provided with Microsoft Access. For more information about Visual Basic for Applications, please refer to the "Building Applications with Microsoft Access 97" manual.



RESOLUTION
If you programmatically remove all pages from a Tab control so that you can rebuild them, after you remove the last page from the control, you can use the CreateControl function to create a new Tab control with two pages on it. Then you can set the properties for the new control and manipulate its pages.

For more information about using the CreateControl function, search the Help Index for "CreateControl function."



STATUS
This behavior is by design.



Steps to Reproduce Behavior
 Start Microsoft Access and open the sample database Northwind.mdb. Create a new form not based on any table or query in Design view. Click the Tab Control button on the Toolbox toolbar, and then click in the Detail section of the form. A Tab control containing two pages appears on the form. Set the Name property of the Tab control to axTabCtl. Save the form as frmTestTab, but do not close the form.</li>  Create a new module and type the following procedure: Function RemoveTabs(c as TabControl) Dim i as Integer For i = c.Pages.Count - 1 to 0 Step -1 c.Pages.Remove Next i     End Function </li> Save the module as basTestTab, and then close it.</li> Press CTRL+G to open the Debug window. Position the Debug window and the frmTestTab form on your screen so that you can see both at the same time.</li> Type the following line in the Debug window, and then press ENTER.

?RemoveTabs(Forms![frmTestTab]![axTabCtl])

Note that the Tab control is removed from the form.</li></ol>

<div class="references_section">