Mousemove Event with Tooltiptext property


Board Regular
May 26, 2004
Hello all. I have a list box in a user form that contains a list of several numbers who's rowsource is Table1. What I would like to do is to create a procedure where a user, when highlighting any number in the list box, would have a tooltip text box pop up displaying a different value in the same record as that number from Table1. For example...


(Col1) (Col2)
Cindy 123456
Carol 654321

123456 and 654321 are displayed in the list box. When 123456 is highlighted with the mouse, a tooltip text box will pop up displaying "Cindy" and will remain as "Cindy" until the mouse moves off of 123456. If the mouse moves to 654321, the tooltip text box will change to "Carol". When the mouse no longer highlights anything in the list box, the tooltip text box disappears.

I'm pretty sure that the MouseMove Event coupled with the Tooltiptext property is required to make this work; the problem is that I have no idea how to make this happen. Any help (especially code) would be greatly appreciated. Thanks in advance, and take care!

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
Rather than using a tooltip, why not just add a column to your list box that has the name that is associated with the number?

If you don't know how to add a column to a list box, it is fairly simple.
Change the number of columns under the Format tag in the properties, and add the associated name to the query that is the list source for your list box.

Upvote 0
The thought had crossed my mind. Unfortunately I have no more room in the form. Therefore, I would like to use the tooptiptext property. Do you know how to do this?
Upvote 0
I'm sorry, I have no idea how to do this with a tool tip. Could you change the list box to a combo box? That way all you have to show is the number until the drop down is activated, then the name column could show wider than the combo box itself.

Sorry I can't offer any better help.
Upvote 0
I don't see anyway of Access knowing what line within the list box the cursor is over. Especially if there are more entries than will fix within the confines of the list box size. Cause once you scroll, the positional point of the mouse would then be tied to its place within the entire record set, and I just don't see Access allowing us to know anything that complicated. The closest I can think of is a two column list box, with the second column to where the user could scroll to the second column to see the name.

Good luck!
Upvote 0

I did a bit of a search. ToolTipText only applies to CommandBars, as far as I can tell. It certainly doesn't appear in the property list of a list box when you scan the options.

I'd suggest an alternative:
1. Use the list box's Click event to pop up a form with a single field, showing the information you need.
2. Use the Exit event to close the popup.
This gets around the space restriction that you mentioned. If the data string you want to display is quite small, you can resize the popup form to take up minimal space.

Post back if this sounds like a viable option for you. It will take:
(a) A small popup form with 2 fields -- the ID (hidden) and the display field
(b) A custom function to pass the correct values to the popup
(c) Two event calls on the list box

Upvote 0
Hi jm14, looks like it is but here goes...

I created a form called frmTest with a listbox, List0. The data that I wanted to display in the popup is in column 3.
The relevant code is below:
Option Compare Database
Option Explicit

Private Sub List0_Click()
    If IsFormLoaded("fdlgToolTip") Then
        DoCmd.OpenForm "fdlgToolTip", acNormal
    End If
End Sub

Function IsFormLoaded(pstrFormName As String) As Integer
  IsFormLoaded = SysCmd(SYSCMD_GETOBJECTSTATE, A_FORM, pstrFormName)
End Function

Private Sub List0_Exit(Cancel As Integer)
    DoCmd.Close acForm, "fdlgToolTip"
End Sub

The popup form is called fdlgToolTip, and contains a single text box called txtItem.
The control source for txtItem is

I set the form so it was just bigger than the textbox, turned off just about everything (record selectors, navigation buttons, control box, maxmin buttons, dividers, scrollbars) and set it to Popup, with a Dialog border.

When you select an item on the list, the popup appears / changes as required. When you hit Tab to leave the listbox, the popup disappears.

Upvote 0

Forum statistics

Latest member

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back