Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ControlTip Text for ControlBox Based on Hovered List Item 1

Status
Not open for further replies.

kjv1611

New member
Jul 9, 2003
10,758
US
I cannot seem to find anything about this in my first search attempts, so not even sure if it is possible. I thought at one point that I had seen some references showing it possible, but I'm just not finding it.

Here's the scenario:

I have a combo box, where I return 3 columns:
1. ItemID
2. ItemName
3. ItemDescription

Ideally, I'd like the ItemName to show (Column 2), and when the user hovers over that item in the listbox, before they've selected it, show the Description in a ControlTip Text box if the Description exists at all - some items have additional description, and some do not.

Is this possible, and can anyone point me in the right direction?

Thanks in advance for any suggestions, references, examples, etc.


"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
This could be very complex especially if the listbox has a scroll bar. In a simple form you could use code like the following. The list box is created in Northwinds based on a Row Source of:

SQL:
SELECT Products.ProductID, Products.ProductName, Suppliers.CompanyName
FROM Suppliers INNER JOIN Products ON Suppliers.SupplierID = Products.SupplierID
ORDER BY Products.ProductName;

Mouse moving over the list box will show the CompanyName in the Tip Text. You will need to adjust the math a little to get this to work.

Code:
Private Sub lboProducts_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim intItemCount As Integer [COLOR=#4E9A06]'number of items displayed[/color]
    Dim dblLBOHeight As Double [COLOR=#4E9A06]'height of list box[/color]
    Dim dblItemHeight As Double [COLOR=#4E9A06]'height of single item[/color]
    Dim intItem As Integer   [COLOR=#4E9A06]'item over[/color]
    intItemCount = 23  [COLOR=#4E9A06]'number of items displayed visible[/color]
    dblLBOHeight = Me.lboProducts.Height
    dblItemHeight = dblLBOHeight / intItemCount
    intItem = Y / dblItemHeight
    Me.lboProducts.ControlTipText = Me.lboProducts.Column(2, intItem)
End Sub

Duane
Hook'D on Access
MS Access MVP
 
Thanks for the example. I'll give it a go as soon as I can. If it ends up being more of a hassle than it's worth, I'll have to move on. If nothing else, I'll count it as a learning experience.



"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top