Listbox Row Tooltip (1 Viewer)

GUIDO22

Registered User.
Local time
Today, 14:38
Joined
Nov 2, 2003
Messages
515
I have found code on an excel forum for creating Tooltips in a Listbox control.. but cant get it to compile in Access ...
Are there any Access/VBA 'gurus' out there that can use this baseline and modify it to work with Access 365 please..?

The code in question is here..
ListBox Row Tooltips

Could be quite helpful for many I am sure...

Thanks in advance.
 

Ranman256

Well-known member
Local time
Today, 09:38
Joined
Apr 9, 2015
Messages
4,339
you cant use: UserForm_Initialize (access don't work that way, it uses tables)

Code:
Private Sub lstBox_AfterUpdate()
lstBox.ControlTipText = lstBox
end sub
 

GUIDO22

Registered User.
Local time
Today, 14:38
Joined
Nov 2, 2003
Messages
515
I'm not sure your understanding of the request. I am trying to add a tooltip to reach row of the listbox. I know Access doesn't work that way.. Hence posting the Api code in the link attached...
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
I have something different that you should be able to adapt for your needs
Have a look at the code I use in Form5 of my example app at

In that example a different image is displayed as the users moves over a listbox. It isn't even necessary to actually select a row.
You would replace the image with a textbox showing the tooltip (which could be a hidden column in the listbox).
QED 😎
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
Just tested my idea - it works perfectly

TooltipExample.gif
 

CJ_London

Super Moderator
Staff member
Local time
Today, 14:38
Joined
Feb 19, 2013
Messages
16,610
Alternative is to use a subform with an image control and text formatted to look like a list box. Same technique can be used to imitate a combo but a bit more work on displaying the selected result
 

KitaYama

Well-known member
Local time
Today, 22:38
Joined
Jan 6, 2022
Messages
1,540
I have something different that you should be able to adapt for your needs
Have a look at the code I use in Form5 of my example app at

In that example a different image is displayed as the users moves over a listbox. It isn't even necessary to actually select a row.
You would replace the image with a textbox showing the tooltip (which could be a hidden column in the listbox).
QED 😎
@isladogs Just FYI the downloaded zip doesn't contain images.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:38
Joined
May 7, 2009
Messages
19,230
It isn't even necessary to actually select a row.
but it actually select it?
if the listbox is Bound and you browse to it just to see the ControlTip it will
alter your selection. if you are careless and forget what was the Original
selection, then it's your problem.
it will only work when All the rows of the listbox are visible?
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
it will only work when All the rows of the listbox are visible?

Almost correct.
The mouse move part only works for listbox items where no scrolling is involved.
However, item selection will still trigger the correct tooltip even if scrolling is used.

I have a possible solution for that mouse move issue which I'm intending to look into
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
@isladogs Just FYI the downloaded zip doesn't contain images.
Thanks. It does now!

EDIT
To avoid that issue in future, i have just updated the example to v7.6 which uses shared images saved in the image gallery

I have also included form 5T with the 'tooltip feature' as used in the video in post #5
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
but it actually select it?
if the listbox is Bound and you browse to it just to see the ControlTip it will
alter your selection. if you are careless and forget what was the Original
selection, then it's your problem.
it will only work when All the rows of the listbox are visible?
You changed your post whilst I was replying earlier.

I don't understand what point you are trying to make now.
First of all the listbox is unbound.
Selecting a listbox item has no effect on the functionality of the mouse move event.
If the listbox has many items and a scrollbar then disable the mouse move feature and just use item selection
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
Attached is an updated version of the listbox 'tooltip' example shown in the video in post #5
The tooltip can be rich text & multi-line if required

Move the mouse over the listbox items to view the associated image & 'tooltip'.
Change the various options such as font name, size etc. It still works

1656366458209.png

It is ONLY necessary to click the listbox item if you have to scroll the listbox down to view a record due to
e.g. large font size or larger number of items

However I have a cunning plan that I think will fix that as well!
 

Attachments

  • ListboxTooltip.zip
    325.7 KB · Views: 161
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:38
Joined
May 7, 2009
Messages
19,230
when All the Items are shown, it will work.
but when only few items are showing, like in this case?
Listbox are not limited to only 10 or 20 items?
 

Attachments

  • ListboxTooltip.accdb
    1.1 MB · Views: 145

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:38
Joined
May 7, 2009
Messages
19,230
It is ONLY necessary to click the listbox item to select it
unfortunately, it does not.
when you make selection (by clicking) and "leave" the listbox, where is your selection now?

this can't be used as Bound control Either.
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
I think you misunderstand the purpose which is to display a series of 'tooltips' as you move over the list.
For clarity in use, I made a deliberate decision to clear the image & tooltip when the mouse leaves the listbox.

I rarely use listboxes bound to a specific field.
If that was a requirement, perhaps the approach could be adapted?

Do feel free to improve on this example if you wish
 

isladogs

MVP / VIP
Local time
Today, 14:38
Joined
Jan 14, 2017
Messages
18,211
I've updated my example app so it now works using mouse move even where the number of listbox rows mean a vertical scrollbar is required.
However, there is no need to physically select a listbox row using a mouse click
As before the row under the mouse cursor is highlighted so the user knows which record is current.

The method used this time does mean there is more noticeable flicker when moving the mouse.
I'm still working on that & will upload the example app when I've (hopefully) reduced the flicker.
In the meantime, see attached video

 

Users who are viewing this thread

Top Bottom