Copyright: Copyright 1994 Microsoft


Table of Contents
Microsoft Access Tab Control

Andrew R. Miller (andrewm@microsoft.com)

July 1, 1994

TAB.OCX is an OLE Custom Control designed to be used with Microsoft Access 2.0.  The control provides a tabbed user-interface, much like the dialogs in Microsoft Word for Windows 6.0 and Microsoft Graph 5.0.  The tab control provides the following features:

* SpecialEffect of Normal or Raised

* Tabs can be located on top, left, right, or bottom borders

* Tab text can be rotated 0, 90, 180, or 270 degrees

* Tab body can be Open or Closed (see below)

* BeforeUpdate and AfterUpdate events

* Works with Access 2.0

Installation

Using the Control

Properties

Events

Methods

Samples

Notes


Installation

1) Copy TAB.OCX to your Access directory.

2) Copy OC1016.DLL to your \WINDOWS\SYSTEM directory.

3) From ProgMan, run MSAREG.EXE C:\WINDOWS\SYSTEM\OC1016.DLL

4) Start Microsoft Access

5) New Form.

6) Choose EDIT INSERT OBJECT from the menu.

7) Click on Controls

8) Click Add New

9) Select TAB.OCX and hit OK.

NOTE: Steps 2 and 3 are not necessary if you have recently installed the ADT.  The ADT installs OC1016.DLL for you,


Using the Control

Using the Tab control should be pretty straight forward.  After inserting it into a form, right click on the control and choose Tab Control Object > Properties from the menu.  This will bring up the OLE Controls property sheet that will allow you to set various properties.  For more information on these properties, see Properties.

A Note About Windowed Controls

OLE Controls are windowed controls, which means they have their own window (Access controls like command buttons typically do not).  In Access, windowed controls paint in a layer above the form, which means you Access controls will never paint on top of a windowed control.  This is a problem for a control like the tab control, since it is designed to live behind other controls.

To get around this, the tab control exposes a property called Body Style.  This property has two settings: Open and Closed.  A closed tab control consists of the tabs on top of a rectangle.  An open tab control is just like the closed control, but the bottom border is not painted.  So, if youre tabs are on the left hand side, the right border of the tab control body will not be painted.

To create a tabbed dialog look, the user can combine an open tab control with an Access rectangle, or with a closed tab control that has been converted to a picture.  Both the Access rectangle and the picture object can live beneath other Access controls, so we avoid the problem described above.

For non-raised tabs, the rectangle will usually work fine.  However, Access built-in 3D effect is different (more subtle) than the tab controls 3D effect, so if youre want the 3D look, you should opt for the closed tab control that has been converted to a picture.

Retrieving the Caption from a Tab

If you need the caption from one tab, use the TabCaption property array.  Just pass it the index of the tab your interested in (0 based), and it will return to you the string that is currently contained in that tab.


Tab Control Properties
Properties

BackColor - The color to use when painting the background of the control.

BodyStyle - Whether or not the tab is open.

0 - Closed

1 - Open

Font - A font object that has these attributes:

Font.Name

Font.Size

Font.Weight

Font.Italic

Font.Strikeout

Font.Underline

SpecialEffect - The special effect for the control.

0 - Normal

1 - Raised

TabCaption() - Read-only property array that returns the caption for a particular tab.

TabLocation - Where the tabs live.

0 - Top

1 - Left

2 - Right

3 - Bottom

TextOrientation - Which way the text faces

0 - Up

1 - Left

2 - Right

3 - Down

TabSizeMethod - How to size the tabs

0 - Fit Evenly with Gap

1 - Fit Evenly

TabText - A semi-colon delimited list of captions for the tabs.

Value - The value of the tab control (what tab is selected, zero-based).

NOTE: This is the default property.


Tab Control Events
Events

BeforeUpdate - Fires before a new tab is selected.  Can be cancelled.

AfterUpdate - Fires after a new tab has been selected.


Tab Control Methods
Methods

The tab control currently has no methods.


Samples

If youre looking for some ideas on how to use the control, check out TAB.MDB, which should have been distributed with this document and the tab control.  This database contains several forms based on NWIND data that use the Tab control.


Notes

This control is not yet complete.  Ive still got some performance work to do, as well as some bug fixes.  If you come across problems, Id like to know about them.

One big feature that will be ready real soon now is different tab styles.  In addition to the tab style currently shown, the control will allow the diagonal tab style (a la Excel workbooks), as well as a rectangular style (not used anywhere, but still kind of cool).  I also hope to provide a Chicago look, but this will probably happen last.