help with the hittest method

GU_mr_Sand_Man

Board Regular
Joined
May 26, 2004
Messages
88
Hello. I am trying to get a small dialog box to pop up when an entry in a listbox is highlighted with the mouse. I believe I need to use the hittest method to make this work. Here's my code thus far:

Code:
Private Sub lstDistrict_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim Item As Object
    Set Item = lstDistrict.HitTest(X, Y)
    If Not (Item Is Nothing) Then
        Me.Caption = Item.Text
    Else
        Me.Caption = ""
    End If
End Sub

When I run this, I get a compile error, "Method or data member not found". How can I resolve this? Also, for my purposes, is the above code correct? Any help would be greatly appreciated.
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Jeremy

I've never heard of such a method.:-?
 
Upvote 0
I ran a Google search on HitTest and it appears that it's possibly part of VB, rather than Access.
You can use it as an API call from Visio, and I've seen examples of its use with the TreeView control (which comes with VB), but not in the context of standard Access controls such a ListBoxes.

What are you trying to do with it? There may be an alternative.

Denis
 
Upvote 0
I would like a small dialog box (kind of like the small yellow box when you highlight code in VB when at a breakpoint; not a message box with vbOkOnly) to pop up when an item in the listbox is highlighted. Is this possible? If so, is there a way to do it without HitTest?
 
Upvote 0
I don't know. Effectively, you want a ToolTip to pop up when you mouse over a list item. Is that correct?

It's not a technique I have come across but I will try to see if anyone else out there has an answer.

Denis
 
Upvote 0
That is abolutely correct. More specifically, I have a listbox full of numbers. When one of those nubmers is selected (using the lstDistrict_MouseMove event), I would like that pop up box to show a text string which is correlated to that number (in a table). Any help you can provide would be wonderful; thank you very much!
 
Upvote 0
Isn't it better, from a user point of view, to use multiple columns to show all the information instead of trying to work around and using pop ups ?
 
Upvote 0
The thought had crossed my mind. Unfortunately I do not have room on the form to display the text string associated with each number in the listbox, so I thought this would be a viable solution. That being said, I am always open to suggestions.
 
Upvote 0
For some reason, this is triggering the strangest sense of deja vu.

<sup>edit</sup> Waiddaminute! What am I doing in the Access Forum?! I rode in on a link and didn't realize where this was. But perhaps those suggestions from Mike & Tom still help? <sub>/edit</sub>
 
Upvote 0
The ToolTipText property sounds exactly like what I need to implement. I'm assuming I need to use the MouseMove Event Proceedure (considering how I want the ToolTipText box to display when an item in the listbox is highlighted). That being said, I'm not sure how to use the ToolTipText with the MouseMove Event Proceedure. Any ideas?
 
Upvote 0

Forum statistics

Threads
1,226,227
Messages
6,189,753
Members
453,567
Latest member
kentbarbie

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 MrExcel.com.
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 "mrexcel.com".
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
Back
Top