Previous Page

CHAPTER  16

Using ActiveX Controls

ActiveX controls extend the functionality of Microsoft Access. You can use Microsoft Access-compatible ActiveX controls to enhance your applications. This chapter describes ActiveX controls and explains how to add them to your application.

Overview of ActiveX Controls

In addition to the standard built-in controls that appear in the toolbox, Microsoft Access supports ActiveX controls, formerly called OLE controls or custom controls. An ActiveX control, like a built-in control, is an object that you place on a form to display data or perform an action. However, unlike a built-in control, the code that supports the ActiveX control is stored in a separate file or files which you must install in order to use the control.

The following ActiveX controls are available for you to use with Microsoft Access:

 The Calendar control, which makes it easy to display and update a monthly calendar on a form. You can choose to install this control when you install Microsoft Access.

 The WebBrowser control, which you can use to display Web pages and other documents in a Microsoft Access form. The WebBrowser control is supplied by Microsoft Internet Explorer version 3.0, which is available in Microsoft Office 97. If you haven't purchased Microsoft Office 97, you can download Microsoft Internet Explorer version 3.0 from Microsoft's main Web site, at http://www.microsoft.com/. When you install Internet Explorer, the WebBrowser control is automatically available for you to use from Microsoft Access.

See Also   For more information on using the WebBrowser control, see Chapter 21, "Developing Applications for the Internet and the World Wide Web."

Other ActiveX controls are available in Microsoft Office 97, Developer Edition and from third-party vendors.

Some ActiveX controls, including the Calendar control and the WebBrowser control, are automatically registered with the system when you install the control files. Others must be registered manually. Once the control has been registered, you can add it to a form that is open in Design view.

You can use the methods, events, and properties associated with a control to manipulate the control's appearance and behavior. In addition, many ActiveX controls can be data-boundthey can store or display data from a field in the form's underlying table or query.

Note   If you distribute an application that uses ActiveX controls, you must make sure that the controls are installed on each computer that runs your application.

Support for ActiveX Controls

Other applications and languages that support ActiveX technologies, such as Microsoft Word, Microsoft Excel, or Microsoft Visual Basic, can support ActiveX controls just like Microsoft Access. However, each application may support a different subset of ActiveX technologies. For this reason, controls that work in some applications may not work in others.

For example, if you've installed Visual Basic or Microsoft Office and the ActiveX controls they include, you may have several ActiveX controls that don't work in Microsoft Access. When you add a control to a form, you may see controls in the list of ActiveX controls that aren't compatible with Microsoft Access. Using a control that hasn't been certified for use with Microsoft Access can cause unpredictable results.

To determine whether a specific ActiveX control is compatible with Microsoft Access, see the documentation provided with the control or contact the vendor of the control.

See Also   For more information on which ActiveX controls are compatible with Microsoft Access, search the Help index for "ActiveX controls."

Types of ActiveX Controls

There are two types of ActiveX controls. The first type is visible both at design time and at run time. An example of this type of ActiveX control is the Calendar control included with Microsoft Access. The Calendar control displays a calendar for a particular month in a particular year, as shown in the following illustration.

After you install the required files, you can place this control on your form. You can use the methods, events, and properties of the Calendar control to:

 Display a calendar for any month of any given year.

 Store a date selected by the user in the current record.

 Trigger an action from an event based on the current date value.

The second type of ActiveX control is visible only at design time. Typically, this type of control is provided to simplify interaction between a Microsoft Access application and one or more dynamic-link libraries (DLLs) or executable files. The ImageList control included in Microsoft Office 97, Developer Edition is an example of this type of ActiveX control.

© 1996 Microsoft Corporation. All rights reserved.

Next Page


Casa de Bender