Dynamic ToolTip?

L

LarryP

Access 2003/Windows XP, continuous form. Looking for a way to modify the
content of a hover-generated Tooltip depending on the value of the textbox
over which the mouse is currently hovering. Specifically, the field in
question contains department names, and when the user hovers his mouse over
one of the departments, I want the ToolTip to display the name(s) of the
contact person(s) for that department -- could be one to many, concatenated
string will do fine in the latter case. (My double-click event for that
control is already in use for something else.)

Any ideas for me?
 
L

LarryP

Oh yeah, since my original post I've got a working solution using the OnEnter
event, but if there's a way I'd still prefer the mouse floatover.
 
A

Arvin Meyer [MVP]

LarryP said:
Access 2003/Windows XP, continuous form. Looking for a way to modify the
content of a hover-generated Tooltip depending on the value of the textbox
over which the mouse is currently hovering. Specifically, the field in
question contains department names, and when the user hovers his mouse
over
one of the departments, I want the ToolTip to display the name(s) of the
contact person(s) for that department -- could be one to many,
concatenated
string will do fine in the latter case. (My double-click event for that
control is already in use for something else.)

Any ideas for me?

Here's some code that will work. Keep in mind that if you list is over 255
characters including commas and spaces, it will fail.

Private Sub txtWhatever_MouseMove(Button As Integer, Shift As Integer, X As
Single, Y As Single)
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim i As Integer

Set db = CurrentDb
Set rst = db.OpenRecordset("qryContacts")

rst.MoveLast
If rst.RecordCount >= 1 Then

Dim strItem As String
Dim strList As String


rst.MoveFirst
For i = 1 To rst.RecordCount
strItem = rst!ContactName
strList = strList & strItem & ", "
rst.MoveNext
Next i

strList = Left$(strList, Len(strList) - 2)
Me.txtWhatever.ControlTipText = strList

End If

End Sub
 
L

LarryP

I see how this will build me a concatenated string of names, but I don't see
how it would "connect" to the current value of txtWhatever (bearing in mind
that I'm dealing with a continuous form, so txtWhatever appears many times
with a different department name each time). Only way I've been able to
handle that so far is to have the user actually click on that control, then
use the OnEnter event. Satisfactory, but not what I really want.
 
D

Dirk Goldgar

LarryP said:
Access 2003/Windows XP, continuous form. Looking for a way to modify the
content of a hover-generated Tooltip depending on the value of the textbox
over which the mouse is currently hovering. Specifically, the field in
question contains department names, and when the user hovers his mouse
over
one of the departments, I want the ToolTip to display the name(s) of the
contact person(s) for that department -- could be one to many,
concatenated
string will do fine in the latter case. (My double-click event for that
control is already in use for something else.)

Any ideas for me?


To do this, I think you could combine the code and techniques from these two
bits of magic by Stephen Lebans:

http://www.lebans.com/tooltip.htm
A2KToolTip.zip is a database containing both an API and Form based
ToolTip solutions. The Form based solution can be used for forms in
DataSheet view.

http://www.lebans.com/conformscurcontrol.htm
ContinuousFormsCurrentRow.zip is a class that allows you to
programmatically access the contents of a bound control, as the user moves
their Mouse, but the control does not have the focus. For Forms in
Continuous View.

Neither one of the above solutions will work by itself, but it should be
possible to combine and modify them to do it.
 
J

Jeff Boyce

I may have confused MouseMove with MouseOver ... have you searched on-line
for MouseOver?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
L

LarryP

Have downloaded but not yet looked closely, but it sounds very much like this
will get me where I need to go. Many thanks (and ain't that LeBans guy
somethin'?)
 
D

Dirk Goldgar

Jeff Boyce said:
I may have confused MouseMove with MouseOver ...


You did, Jeff. There's no MouseOver event in Access. It's MouseMove he
would use, but it's tricky to get info from a record that isn't current.
Stephen Lebans has suggested that two of his solutions could be combined to
do it; see the reply I posted.
 
M

Marshall Barton

LarryP said:
Access 2003/Windows XP, continuous form. Looking for a way to modify the
content of a hover-generated Tooltip depending on the value of the textbox
over which the mouse is currently hovering. Specifically, the field in
question contains department names, and when the user hovers his mouse over
one of the departments, I want the ToolTip to display the name(s) of the
contact person(s) for that department -- could be one to many, concatenated
string will do fine in the latter case. (My double-click event for that
control is already in use for something else.)


There's examples on the ToolTip page at www.lebans.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top