ACC2: Simple Method for Creating ToolTips for Form ControlsID: Q132379
|
This article describes a method that you can use to add custom ToolTips
(brief descriptions that appear when the mouse pointer moves over
particular controls) to forms.
This article assumes that you are familiar with Access Basic and with
creating Microsoft Access applications using the programming tools provided
with Microsoft Access. For more information about Access Basic, please
refer to the "Building Applications" manual.
This method creates ToolTips by using a text box, the Tag property of form
controls, and a custom function that is triggered by the MouseMove event of
form sections and controls. For example, when you move the mouse pointer
over a particular control, the MouseMove event triggers the custom
function. The function moves a text box displaying a brief description
stored in the control's Tag property under the control.
This method uses a single text box to display the ToolTip messages
for all the controls. Be aware, however, that the size of the text box is
not adjusted for descriptions of varying lengths. To avoid cutting off the
ToolTip text, use a set number of characters for the control descriptions.
To add custom ToolTips to a form, follow these steps.
Name: ToolTip
Visible: No
BackColor: 8454143
Name: MyButton.
Tag: My Button
OnMouseMove: =ShowToolTip("MyButton")
Function HideToolTip()
Dim z As Integer
On Error Resume Next
If Me!ToolTip.Visible = True Then
Me!ToolTip.Visible = False 'Turn off the ToolTip.
z = SysCmd(SYSCMD_CLEARSTATUS)
End If
End Function
=HideToolTip()
Option Explicit
Function ShowToolTip (ShowControl As String)
Dim MyControl As Control
Dim MyToolTip As Control
Dim z as Integer
Const Separator = 80
On Error Resume Next
Set MyControl = Screen.ActiveForm(ShowControl)
Set MyToolTip = Screen.ActiveForm!ToolTip
If MyToolTip.Visible = False Then
MyToolTip = MyControl.Tag
MyToolTip.Left = MyControl.Left + (Separator * 2)
MyToolTip.Top = MyControl.Top + MyControl.Height + Separator
MyToolTip.Visible = True
' Optional: Display ToolTip on the Status Bar.
z = SysCmd(SYSCMD_SETSTATUS, MyToolTip.value)
End If
End Function
For more information about creating ToolTips using Windows Application
Programming Interface (API) functions, please see the following article in
the Microsoft Knowledge Base:
Q119991 ACC2: How to Add ToolTips to Form Controls
Additional query words: tool tips
Keywords : kbusage FmsHowto
Version : 2.0
Platform : WINDOWS
Issue type : kbhowto
Last Reviewed: April 28, 1999