The information in this article applies to:
Advanced: Requires expert coding, interoperability, and multiuser skills. SUMMARYThis article describes how to reference individual command buttons placed on a custom Toolbar control. The custom Toolbar control is included with the Microsoft Office 97 Developer Edition Tools and the Microsoft Access Developer's Toolkit version 7.0. MORE INFORMATION
This article assumes that a form with a custom Toolbar control has already
been created. For the examples provided in this article, the custom Toolbar
control should have at least two command buttons.
When you click a button on the custom Toolbar control, the toolbars
ButtonClick event is triggered. It is important to note that the Toolbar
control has both a Click event and a ButtonClick event. To determine which
button someone clicked, the ButtonClick event must be used.
Each button in the Button collection has an "index" value and an optional key value. These values can be used to reference the desired button when selected. To view the index or key value of a particular button, using the right mouse button (right click), click the custom Toolbar control in form Design view, point to Toolbar Control Object, and then click Properties. Within the ToolbarControl Properties window, click the Buttons tab. The Buttons tab shows the Index value of a particular button and a key may also be provided. The code examples below assumes there are at least two buttons on the custom Toolbar control. This example will display an appropriate message box, depending on which button was selected. In this example, the Button collections index property is used to determine which button was pressed. The index value stores an integer. Each button in the buttons collection will have a unique index value. Enter the code in the Toolbar control's ButtonClick event. To enter this code, on the View menu, click Code while in the form's Design view. Then, select the Toolbar custom control object from the Object list and ButtonClick from the Proc list. NOTE: The following code will not work within the Toolbar control's Click event when using Microsoft Access for Windows 95.
The next example shows how to perform the same actions by referencing the
Button collections "key" value instead of its Index value. The key value
stores a string and this value is optional. If the key value is used, each
button in the button collection should have a key and the key value must be
unique.
NOTE: The index values for buttons in the Button collection are
automatically assigned by their sequential order in the custom Toolbar
control. If a button is removed, the index values are reassigned to all of
the buttons in the collection. For reliable code, use the "key" value when
referencing buttons. This value is user defined and cannot be changed by
removing a button in the collection.
REFERENCESFor more information about the Toolbar control, search the Help Index for "Toolbar Control." Additional query words:
Keywords : kbinterop |
Last Reviewed: July 21, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |