Question

faster version of controltip to display tooltip text

Asked by: rberke

On my machine with access 2003, controltip takes about 5 seconds to display, which is annoying.

So, I am looking for a simple way to speed things up.   A tools option (or even a registry hack) changing the 5 second delay to a 1 second delay would be great.

But, since I don't know how to do this, the attached code using the mousemove event is the best I can come up with.
There are several problems
#1,  Every form needs its own control named "myToolTip"
#2,  I would like to code the mousemove events to be =tooltipper() instead of =tooltipper("form","controlname").
      I tried saying =tooltipper(Me), but that does not work.
#3,  The tooltipper subroutine runs about 500 times a second for as long as the mouse is in the control


I hope someone can help

rberke

Option Compare Database
Option Explicit
Function tooltipper(ctl, ctlName)
 
Dim myMe, myCtl
If TypeName(ctl) = "String" Then
    Set myCtl = Forms(ctl)
Else
    Set myCtl = ctl
End If
Debug.Print ctlName & Now()
Set myMe = myCtl.Controls(ctlName)
' MsgBox myctl.FormName
With myCtl.[myToolTip]
    .Caption = myMe.ControlTipText
    .Top = myMe.Top - 300
    .Left = myMe.Left
End With
End Function
                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:

Select allOpen in new window

  • db4.mdb
    • 136 KB

    open database form, then hover over text boxes to see tooltip

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2009-10-28 at 13:53:45ID24852710
Tags

ms access controltip tooltip controltiptext hover yellow telltale mouse

Topic

Microsoft Access Database

Participating Experts
2
Points
500
Comments
29

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. MouseMove Event
    I've got a series of buttons on a form. I want the buttons BackColor proprty to change from default gray to red when the user's mouse moves over the button. The buttons' Style is set to Graphical. I know how to make the button change colors once, but not change back to def...
  2. multiline tooltips
    how can i create a multiline tooltip?
  3. Points for:  rberke
    http://www.experts-exchange.com/Applications/MS_Office/Excel/Q_20816447.html hi rberke, you are right, my solution was incomplete Rajesh

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: DatabaseMXPosted on 2009-10-28 at 13:57:10ID: 25688258

 

by: puppydogbuddyPosted on 2009-10-28 at 14:24:39ID: 25688503

Hi Rob,
See this link:  http://blogs.msdn.com/access/archive/2009/08/24/cool-tool-tips-a-better-control-tip.aspx
                        (has a free sample demo mdb that you can download)

The tip is read from the control's Tag property when a control with a tip gets the focus, and the tip is hidden when the control loses the focus. Clicking on the tip while it is displayed hides the tip.  A Tip's heading and text are separated by a "~" delimiter in the string assigned to a control's Tag property. The string is parsed by a generic public function in a module, called by another generic function behind the form.


 

by: DatabaseMXPosted on 2009-10-28 at 14:34:23ID: 25688589

"Grading Comment:
ma sha'a allah
i pray for you
thank you very much"

You are welcome.

mx

 

by: rberkePosted on 2009-10-28 at 15:35:16ID: 25689007

lebans is WAY overkill for what I want.  about 20 pages of code, and a lot of API calls.

Cool-tips approach does not work when you mouse hovers over a command button, which is what I actually desire.

If MS Access allowed application.ontime, I could do something like the attached.

But, Ontime does not exist in Access, so that approach will not work.

Anybody else have any good ideas?

Bob

Dim lastTool
Function tooltipper(ctlForm, ctlname)
If lastTool = ctlForm & ctlname Then Exit Function
lastTool = ctlForm & ctlname
 
Call clearLastToolTip
Dim cmd
 
Call tooltipperDoit(ctlForm, ctlname)
cmd = "tooltipperdoit ' & ctlfrom & " ', & '" & ctlname & "'"
Application.ontime TimeValue("00:00:03"), "clearlasttooltip"
End Function
 
Sub tooltipperDoit(ctlForm, ctlname)
Dim myMe, myCtl
Set myCtl = Forms(ctlForm)
 
Debug.Print ctlname & Now()
Set myMe = myCtl.Controls(ctlname)
' MsgBox myctl.FormName
With myCtl.[myToolTip]
    .Caption = myMe.ControlTipText
    .Top = myMe.Top - 300
    .Left = myMe.Left
End With
End Sub
 
Sub clearLastToolTip(ctlForm, ctlname)
Dim myCtl
Set myCtl = Forms(ctlForm)
myCtl.[myToolTip].Visible = False
End Sub
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:

Select allOpen in new window

 

by: puppydogbuddyPosted on 2009-10-28 at 22:47:34ID: 25690955

Rob,
I believe you can simulate the "hover" effect for your buttons by calling the 2 mouse move events shown below.

Private Sub MyToolTip_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MyToolTip.Caption = "This is a tool Tip" 'Place your tool tip here
End Sub

Private Sub YourForm_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MyToolTip.Caption = "" 'Replace the tool tip with a blank string here
End Sub

 

by: rberkePosted on 2009-10-29 at 17:21:36ID: 25699369

Puppydog,  the "Yourform_mousemove" idea helped, and my tooltipper is nearing completion.

It works well when myform.Text6.onmousemove  = [event procedure] which then calls  Tooltipper(Me,"Text6")

But, I want to skip writing an event procedure.  Instead I want to set  myform.text6.onmousemove
to be   "=tooltipper([me],"text6").      

Unfortunately, the above code does not work, and I am beginning to think it is impossible.

Any ideas?



 

by: rberkePosted on 2009-10-29 at 19:00:15ID: 25699740

I still wish I could figure out syntax for tooltipper([me]...).

But, the attached database seems to work pretty well, and handles command buttons fine.

Unfortunately, ActiveControl  does NOT point to the control the mouse is hovering over.

Without that, no matter how hard i tried, =tooltipper2(0) did not work so I gave up.

Now, each control has onmousemove set to =tooltipper2("control name")

I still hope somebody can improve on this approach.

Option Compare Database
<<STANDARD MODULE>>
 
Option Explicit
Dim cnt As Long
Dim currentTooltip As Control
Dim currentTooltipName As String
 
Function tooltipperoff()
' If TypeName(currentTooltip) = "Label" Then currentTooltip.Visible = False
On Error Resume Next
currentTooltip.Visible = False
currentTooltipName = ""
 
End Function
 
 
Function tooltipper(ControlOrForm As Variant, ctlNameOrZero) ' if you don't pass a ctlName the first parameter must be not be a form
' PUT THE FOLLOWING CODE IN Form_YourForm  module
'      Function tooltipper2(x)
'      Call tooltipper(ActiveControl, x)
'      End Function
 
' THEN IN EVERY CONTROL THAT NEEDS A FASTER TOOLTIP, INSTALL THE FOLLOWING ONMOUSEMOVE FUNCTION
'      =tooltipper2("cmd10")
'  EVENTUALLY, I HOPE TO ALLOW THE FOLLOWING TO WORK
'     =tooltipper2(0)
'  BUT, FOR NOW, THE ONLY RELIABEL APPROACH IS TO PASS THE CONTROL NAME "cmd10"
'     =toolTipper2("cmd10")
'
 
Dim hoveredTextBox As Control, ctlName As String, ctlForm As Form
Select Case Left(TypeName(ControlOrForm), 4)
    Case "Form"
        Set ctlForm = ControlOrForm
        ctlName = ctlNameOrZero
    Case Else
        Set ctlForm = ControlOrForm.Parent
        If ctlNameOrZero = 0 Then
            ctlName = ControlOrForm.Name
        Else
            ctlName = ctlNameOrZero
        End If
    End Select
    
 
If ctlName = currentTooltipName Then Exit Function
 
Set hoveredTextBox = ctlForm.Controls(ctlName)
Set currentTooltip = ctlForm.Controls("myToolTip")
currentTooltipName = ctlName
 
If ctlName = "0" Then MsgBox "a control in " & ctlForm.Name & " needs to call tooltipper2('control name')"
 
 
If ctlForm.OnMouseMove = "" Then ctlForm.OnMouseMove = "=tooltipperoff()"
If ctlForm.Detail.OnMouseMove = "" Then ctlForm.Detail.OnMouseMove = "=tooltipperoff()"
' MsgBox ctlName
With currentTooltip
    .Visible = True
    .Caption = hoveredTextBox.ControlTipText
    On Error Resume Next
    .Top = hoveredTextBox.Top + hoveredTextBox.Height
    If Err Then
        .Top = hoveredTextBox.Top - 300
    End If
    On Error GoTo 0
    .Left = hoveredTextBox.Left
End With
End Function
                                              
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:

Select allOpen in new window

  • db4.mdb
    • 212 KB

    OPEN DB4, then open mainform and hover mouse over command button

 

by: puppydogbuddyPosted on 2009-10-29 at 23:08:19ID: 25700458

Hi Rob,
Looks good! The only thing that comes  mind is that you might want to come up with a recursive procedure that would allow you to recurse the code for a subform.  below is an example that might give you some ideas that you could apply to your app.

Public Sub YourSubName(frm As Form)
'the procedure call from any form looks like this:  Call YourSubName(Me)

    On Error GoTo Error_Routine
   
    Dim ctl As Control
    Dim strForm As String
    Dim x As Integer

    strForm = frm.Name
   
For Each ctl In frm.Controls
    If ctl.Name <> "btnYourButton" Then
            Select Case ctl.ControlType
                Case acComboBox, acListBox, acTextBox
                    If Forms!YourMainform!btnYourButton.Caption = "View (Horizontal)" Then
                        If InStr(ctl.Tag, "View1") > 0 Then
                            ctl.Visible = True
                        'If InStr(ctl.Tag, "View2") > 0 Then
                        '    ctl.Visible = False
                        End If
                    ElseIf Forms!YourMainform!btnYourButton.Caption = "View (Vertical)" Then
                        If InStr(ctl.Tag, "View1") > 0 Then
                            ctl.Visible = False
                       ' ElseIf InStr(ctl.Tag, "View2") > 0 Then
                       '     ctl.Visible = True
                        End If
                    End If
               Case acSubform                     'recursive code
                    Set frm = Forms!YourMainform!YourSubformControl.Form
                    Call YourSubName(ctl.Form)
           End Select
       End If
Next ctl
Exit_Continue:
        Exit Sub
Error_Routine:
        MsgBox "Error# " & Err.Number & " " & Err.Description
MsgBox "test " & x & " " & ctl.Name
        Resume Exit_Continue

End Sub
 

 

by: rberkePosted on 2009-10-30 at 04:50:38ID: 25701966

Maybe I understand, and maybe I don't.

Clearly, the code you posted came from one of your applications that dealt wih other issues.
I think you are suggesting that I modify it to something like the attached.

I also think you are suggesting the code be a "One Shot" where I run the PrepareForm sub once while designing my target form, then save the result.  

Could you please tell me if my interpretation of your comments is correct?

In anycase, this has been a fun project, which could be extended quite a bit.  I wish I had the time to devote more efforts.

For instance, the target form would need further modifications such as adding the following code to each Form_ xxx  module.  If we use PerpareForm as a One Shot, that could be a manual step. But perhaps the PreparForm routine could add tooltipper2 automatically?  If so, the PrepareForm might be run on Form load.

Or maybe would could even set up  class module that intercepts the events from ALL forms automatically?  I have done that kind of thing in Excel, but never in MS Access.

But, all those things are more work than I can afford, so I will be closing this questions soon.



'      Function tooltipper2(x)
'      Call tooltipper(ActiveControl, x)
'      End Function


...... possible modifications .....
 
Public Sub PrepareFormForTooltipper(frm As Form)
'the procedure call from any form looks like this:  Call YourSubName(Me)

    On Error GoTo Error_Routine
   
    Dim ctl As Control
    Dim strForm As String
    Dim x As Integer

    strForm = frm.Name
   
For Each ctl In frm.Controls
    If ctl.Name <> "btnYourButton" Then
            Select Case ctl.ControlType
                Case acComboBox, acListBox, acTextBox
                        if ctl.onmousemove = "" and ctl.controltip <> "" then
                             Ctl.onmousemove = "=tooltipper2(" & Chr(34) & ctl.name & chr(34) & ")"
                        End if             
               Case acSubform                     'recursive code
                    Set frm = Forms!YourMainform!YourSubformControl.Form
                    Call YourSubName(ctl.Form)
           End Select
       End If
Next ctl
Exit_Continue:
        Exit Sub
Error_Routine:
        MsgBox "Error# " & Err.Number & " " & Err.Description
MsgBox "test " & x & " " & ctl.Name
        Resume Exit_Continue

End Sub
 

 

by: puppydogbuddyPosted on 2009-10-30 at 06:17:59ID: 25702615

Rob,
My comments were only intended to address the following:
1.  The idea of making your Tooltipper recursive with respect to a subform
2. Give you an example of how to call the Tooltipper Routine using the Me object
3. Give you other ideas.

My comments were not intended to convey to you the idea of running the Tooltipper once for each form.  In fact, I believe the tip should be displayed each time the control has focus if the user has indicated (via a button or checkbox) that he wants tooltips to be visible. ...to this end you might want to experiment with conditional formatting....perhaps changing the background color of the control that has focus (active control), and then use the presence of a certain color to trigger the ToolTip...there are many different roads you could take....if only there were enough time!

 

by: rberkePosted on 2009-10-30 at 07:48:18ID: 25703467

I agree that that my tool tips should display each and every time a mouse goes over the control. But, I think you misunderstood two minor points:

1. my wish to pass Me to a subroutine was not about  how to do it from Vba. I was asking how to do it in form design view using the onMouseMove property WITHOUT coding an event procedure.

2. You said "the tip should be displayed each time the control has FOCUS".  As you know, mousemove is totally different from focus, with the key difference being that it does not change the ActiveControl. It is this key difference that caused cool-tool-tips to fail when I tried to put it into onmousemove.  

You may not have noticed, but I have fixed that in my routine. Putting =tooltipper2("ctlName") into onmousemove property causes tool tips to pop up UPON HOVERING.  

On the other hand, =tooltiper2("ctlName") also works well in the ongotfocus property.  It postpones the pop up until the user actually clicks on the control.

So, my routine works in both kind of events whereas the cool-tool-tips techniques only works in the gotfocus and lostfocus routines.

Using gotfocus has some advantages (text boxes work nicely with no need for cpu intensive mousemove subroutines ) and some disadvantages (command buttons don't work).  Weighing advantage versus disadvantages requires human thought for each control, so a recursive call would require artificial intelligence to pick properly.

So, for now, I think I will leave well enough alone, and not go the recursive route or make any futher improvements.


So, thanks for your help, and I am closing the problem.  

 

by: rberkePosted on 2009-10-30 at 08:02:17ID: 25703646

And, this might  clarify my issue with passing Me directly from the onMouseMove property.

I wanted the control's design to say
syntax1    on mouse move:  =tooltipper([me],"ctlName")


I "resolved" that issue by putting the tooltipper2 function into each and every form_myform.x. module that needed my feature.  That way, the control's design could say
syntax2    on mouse move:  =toolTipper2("ctlName")

If I could get syntax1 to work, I would NOT require any tooltipper2 functions, and I would not have to modify any form_myform.x. module.
 

 

by: puppydogbuddyPosted on 2009-10-30 at 12:10:07ID: 25705959

Hi Rob,
You said <<<<<<I wanted the control's design to say
syntax1    on mouse move:  =tooltipper([me],"ctlName")>>>>>

Try this:
_________________________________________________
..............Module Code..............................
Public Function Tooltipper(frm As Form, ctl As Control)
XXXXXXXXXXX  Your module code XXXXXXXXXXXXX
End Function

..............Calling Form Code in Mouse Move event .........................
Dim frm As Form
Dim ctl As Control
Set frm = Me        'if me doesn't work, try Me.Form  or try Screen.ActiveForm
Set ctl = Me.ActiveControl

frm.OnMouseMove = tooltipper(frm, ctl)



 

by: rberkePosted on 2009-10-30 at 14:15:51ID: 25706854

No!, frm.OnMouseMove is a string, so that code can't work.

Besides, if what I wanted to do was possible, it would be available in design view without using vba.

To continue to clarify, look at the attached JPG so you can really understand what I am trying to do.

 

by: puppydogbuddyPosted on 2009-10-30 at 15:30:09ID: 25707198

Rob,
frm.OnMouseMove a string? No way......Look at my  Dim and Set statements......frm and ctl are declared and set as objects that have properties and methods.  if I needed to convert frm to a string I would use the .Name property of frm, which would return the object name as a string>>>>>frm.Name.  Hope that clarifies it for you.

 

 

by: rberkePosted on 2009-10-30 at 19:42:29ID: 25708125

see attached

  • db5.mdb
    • 136 KB

    hover mouse over the text box and you will see onmousemove is a string

  • temp.jpg
    • 99 KB

    follow the arrows

    follow the arrows
 

by: rberkePosted on 2009-10-30 at 20:05:41ID: 25708179

Puppydogbuddy, I know you are rated as a genius in MS Access, and you have helped me before.

So, I suspect the problem is that I am not communicating my issue very even after several attempts.

But, if you look carefully at the big red arrow in the first JPGs I posted, I think it will start to make sense.  

The red arrow points to     "on mouse move . . . . . . =tooltipper([me],"text8")

But, you have to understand that the red arrow is pointing to text8.onmousemove which is a property that is a STRING. It contains text that happens to look like vba code.  That string is probably never compiled, I think MS Access has an interpreter that parses it at the appropriate time. Since it is not actually compiled, that may explain why putting [me] or me or Me does not work.  The details of that are a little vague, but I am 100% certain that your suggested code of
frm.OnMouseMove = tooltipper(frm, ctl)  WILL NOT WORK.

 

by: puppydogbuddyPosted on 2009-10-30 at 20:42:53ID: 25708281

Rob,
A string does not have properties and methods;an object has properties and methods.  Instead of using debug.print which outputs a string, try using intellisense: type  Me. (for example) and you will see the properties and methods exposed for declared and initialized object variables.

Also, see this link that I just found for Mouse Positioning, and note the objects that appear in the snippet.
                             http://www.vb-helper.com/howto_position_form_under_mouse.html

 

by: puppydogbuddyPosted on 2009-10-30 at 21:01:57ID: 25708356

Rob,
see also this link:
                   http://articles.techrepublic.com.com/5100-10878_11-5648718.html

 

by: rberkePosted on 2009-10-30 at 21:54:38ID: 25708509

Sorry, but you seem to think I don't understand the basics.  In this particular area, I think I may actually know a little more than you in this particular area.  Your code will not work PERIOD. END OF STORY. NO DEBATE.  Try it yourself and you will see that you get a run time error when you try frm.onmousemove = tooltipper(frm,ctl).  

Anyway, I have found a solution to my problem which dramatically simplifys the rouine.  It was staring us in the face, and both you and I should oth have seen it.  the key is put the following at the big red arrow.

  =tooltipper([text8])    then, there is no need to pass Me  because the control itself has all necessary info

That simple.

This leads to a dramatic simplification of the routine. Everything is done in the standard module.

Option Compare Database
Option Explicit
Dim currentCtl As Control
Dim currentTooltip As Control


Function tooltipperoff()
Call tooltipper(Nothing)
End Function
Function tooltipper(ctl As Control)
' thanks to http://easyweb.easynet.co.uk/trevor/AccFAQ/forms.htm#ctrlUnderMouse
' also see http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24852710.html
'
' this makes controltiptext appear much faster for specific controls

If ctl Is Nothing Then
    If TypeName(currentTooltip) = "Label" Then currentTooltip.Visible = False
    Set currentCtl = Nothing
    Exit Function
End If

If currentCtl Is Nothing Then
    Set currentCtl = ctl
ElseIf currentCtl.Name = ctl.Name Then
    Exit Function
End If

With ctl.Parent
    Set currentTooltip = .Controls("myToolTip")
    If .OnMouseMove <> "=tooltipperoff()" Then .OnMouseMove = "=tooltipperoff()"
    If .Detail.OnMouseMove <> "=tooltipperoff()" Then .Detail.OnMouseMove = "=tooltipperoff()"
End With

With currentTooltip
    .Visible = True
    .Caption = ctl.ControlTipText
    On Error Resume Next
    .Top = ctl.Top + ctl.Height
    If Err Then
        .Top = ctl.Top - 300
    End If
    On Error GoTo 0
    .Left = ctl.Left
End With
   
End Function


Sub CreateSetCtlUnderMouse(pfrm As Form)
' the following makes it easier to set a bunch of controls
' select the objects you want to have this done to using [Shift] + Click, then open the code window, and in the immediate window type:
'   CreateSetCtlUnderMouse Me
Dim ctl As Control, i As Integer
  For i = 0 To pfrm.Count - 1
    Set ctl = pfrm(i)
    If ctl.InSelection Then
      ctl.OnMouseMove = "=Tooltipper([" & ctl.Name & "])"
    End If
    Set ctl = Nothing
  Next

End Sub

 

by: rberkePosted on 2009-10-30 at 21:56:13ID: 25708515

sorry for  the typos.  It is late and I am going to bed

 

by: puppydogbuddyPosted on 2009-10-31 at 05:25:33ID: 25709432

Rob,
Congratulations on pursuing this to the point that you have come up with a much more efficient and simplified way to handle tooltips.  I would hope you know more about the intimate details of the application than I do.  Since I have never used this approach to tooltips, my role here was to provide you with some ideas and technical support.

I think we misunderstood each other about some things....for example, I never intended to convey that frm.onmousemove was the exact syntax....I was merely trying to convey that the object variable approach using VBA, not only was workable, but was the preferred path to follow.

your original>>>>   on mouse move.... =tooltipper([me],"text8")
my suggestion>>   frm.OnMouseMove = Tooltipper(frm, ctl)
your final>>>>>     ctl.OnMouseMove = "=Tooltipper([" & ctl.Name & "])"

 

by: rberkePosted on 2009-10-31 at 05:38:30ID: 25709491

Slightly improved version

Option Compare Database
Option Explicit
Dim PreviousCtl As Control
Dim PreviousTooltip As Control


Function tooltipperoff()
' turn off previous tooltip and restore previous control's onmousemove
    If TypeName(PreviousTooltip) = "Label" Then
        If PreviousTooltip.Visible Then PreviousTooltip.Visible = False    ' if condition prevents properties screen from flickering
    End If
    Set PreviousCtl = Nothing
End Function
Function tooltipper(ctl As Control)
' thanks to http://easyweb.easynet.co.uk/trevor/AccFAQ/forms.htm#ctrlUnderMouse
' also see http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24852710.html
'
' this makes controltiptext appear much faster for specific controls
If PreviousCtl Is Nothing Or TypeName(PreviousCtl) = "Object" Then
    Set PreviousCtl = ctl  ' first time the mouse enters control
ElseIf PreviousCtl.Name = ctl.Name Then
    Exit Function           ' mouse continutes to be in the control
End If
' If ctl.Name = "Text9" Then Stop
With ctl.Parent
    Set PreviousTooltip = .Controls("myToolTip")
    If .OnMouseMove <> "=tooltipperoff()" Then .OnMouseMove = "=tooltipperoff()"
    If .Detail.OnMouseMove <> "=tooltipperoff()" Then .Detail.OnMouseMove = "=tooltipperoff()"
End With

With PreviousTooltip
    .BackColor = vbYellow
    .BackStyle = 1 ' normal
    .Width = 2700
    .Visible = True
    .Caption = ctl.ControlTipText
    .Left = ctl.Left
    On Error Resume Next
    .Top = ctl.Top + ctl.Height
    If Err Then .Top = ctl.Top - 300
    On Error GoTo 0
End With
   
End Function

 

by: rberkePosted on 2009-10-31 at 09:18:07ID: 25710294

puppydogbuddy:  I agree with your last comments.

Also, I again have to thank you for your excellent link to cool-tool-tips.  Without that link, I don't think I would have solved my problem.  And, your idea of recursion is not a dead issue, I have a few ideas that may eventually use it.

That's what is great about experts exchange, two minds are better than one. As long as we have persistance and tenacity,  good things can happen.

So long for now, till we meet again.

Bob

 

by: puppydogbuddyPosted on 2009-10-31 at 10:15:19ID: 25710526

OK, Bob.....and congrats again on building a better mousetrap!

 

by: rberkePosted on 2009-11-01 at 10:44:23ID: 25714820

When mouse is hovering over a control, MouseMove was executing about 200 times a second. In my old code, the 1st execution did some work and the remaining hundreds of executions simply did an Exit Function.

In today's version the 1st execution "temporarily turns off onmousemove", then restores it when the hover ceases.  The hundreds of wasted executions are gone, so much less computer time will be wasted.

Sometime in the future, I hope to programmatically add the "myToolTip" label to the form, so the programmer does not need to do so.

But, no more improvements will be posted here.  I doubt if anybody but me is interested in this anyway.

Option Compare Database
Option Explicit
Dim ThisCtl As Control
Dim PreviousTooltip As Control


Function toolTipper(ctl As Control)
'
'  This program will improves on microsoft's controltip application.
'  right now, it simply makes the tooltip appear much faster (instead of 5 seconds after the mouse hover starts)
'
'  eventually, this can be easily enhanced.  For instance different controltips could show in each user's native language.
'  or perhaps a two level help system. Hover over a control and level 1 help appears. click on the control and more verbose help appears.
'
'  to run this,
'  1 install this code into a standard module,
'  2. put the following function calls into onMouseMove for each desired control
'            =toolTipper([controlName])
'  3. if you have many desired controls, see CreateSetCtlUnderMouse for a way to do them all at the same time._
'
' thanks to http://easyweb.easynet.co.uk/trevor/AccFAQ/forms.htm#ctrlUnderMouse
' thanks to http://blogs.msdn.com/access/archive/2009/08/24/cool-tool-tips-a-better-control-tip.aspx
' thanks to puppydogbuddy at http://www.experts-exchange.com/Microsoft/Development/MS_Access/Q_24852710.html
'

Select Case TypeName(ThisCtl)
    Case "Nothing", "Object"
    Case Else
        If ThisCtl.Name <> ctl.Name Then
            Call toolTipperoff  ' Mouse is no longer hovering over ThisCtl, so turn it off
        Else
            MsgBox "this should never happen"
            Exit Function
        End If
End Select

' Set ThisCtl = ctl  ', ====== this must NOT be done here. first we must check if .controls("myToolTip") exists

ctl.OnMouseMove = "" ' turn off mouse move for as long as the mouse is inside this control
                    ' the mouse move will be restored in tooltipperoff
With ctl.Parent
    On Error Resume Next
    Set PreviousTooltip = .Controls("myToolTip")
    If Err <> 0 Then
        MsgBox "" _
            & vbCrLf & ctl.ControlTipText _
            & vbCrLf & vbCrLf & "The tooltip above will not be shown again because " _
            & "'" & ctl.Parent.Name & "' does not have a Label named 'myToolTip'." _
            & "Contact the programmer to resolve this problem." _
            & ""
        Exit Function
    End If
    On Error GoTo 0
    Set ThisCtl = ctl
    If .OnMouseMove <> "=tooltipperoff()" Then .OnMouseMove = "=tooltipperoff()"
    If .Detail.OnMouseMove <> "=tooltipperoff()" Then .Detail.OnMouseMove = "=tooltipperoff()"

End With

With PreviousTooltip
    .BackColor = vbYellow
    .BackStyle = 1 ' normal
    .Width = 2700
    .Visible = True
    .Caption = ctl.ControlTipText
    .Left = ctl.Left
    On Error Resume Next
    .Top = ctl.Top + ctl.Height
    If Err Then
        Err.Clear
        .Top = ctl.Top - 300
        If Err Then
        On Error GoTo 0
            .Top = ctl.Top
        End If
    End If
    On Error GoTo 0
End With
   
End Function

Function toolTipperoff()
' turn off previous tooltip and restore previous control's onmousemove
    If TypeName(PreviousTooltip) = "Label" Then
        If PreviousTooltip.Visible Then PreviousTooltip.Visible = False    ' if condition prevents properties screen from flickering
    End If
    If Not ThisCtl Is Nothing And TypeName(ThisCtl) <> "Object" Then
        ThisCtl.OnMouseMove = "=Tooltipper([" & ThisCtl.Name & "])"
        Set ThisCtl = Nothing
    End If
End Function

Sub CreateSetCtlUnderMouse(pfrm As Form)
' the following makes it easier to set a bunch of controls
' select the objects you want to have this done to using [Shift] + Click,
' then open the code window, and in the immediate window type:
'   CreateSetCtlUnderMouse Forms("tstForm")
Dim ctl As Control, i As Integer
  For i = 0 To pfrm.Count - 1
    Set ctl = pfrm(i)
    If ctl.InSelection Then
      ctl.OnMouseMove = "=Tooltipper([" & ctl.Name & "])"
    End If
    Set ctl = Nothing
  Next

End Sub


  • db4.mdb
    • 228 KB

    open mainform and hover your mouse over each control

 

by: puppydogbuddyPosted on 2009-11-01 at 21:10:47ID: 25717165

Bob,
You would be surprised at how many people are interested in the  improved tooltipper that you have created!  Thanks for sharing your methodology and code.

 

by: rberkePosted on 2009-11-03 at 08:34:26ID: 25730704

Well, you are probably just being kind and if so, thank you very much.

But, if anyone is really interested in using this code, they should post a "what is the status?" message here before copying my code.  

I have noticed a few other issues that I have postponed indefinitely. But I might give them higher priority if I know someone really cares.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...