On mouse hoover event , display a text (1 Viewer)

aman

Registered User.
Local time
Today, 09:01
Joined
Oct 16, 2008
Messages
1,250
Hi Guys

I don't want to display a proper message box but just on the mouse hover event I want to display a text and it will hide automatically when no mouse hover on that label.

Any help will be much appreciated.

Thanks
 

Beetle

Duly Registered Boozer
Local time
Today, 10:01
Joined
Apr 30, 2011
Messages
1,808
Open the properties for the label, go to the Other tab, under Controltip Text put your message.
 

isladogs

MVP / VIP
Local time
Today, 17:01
Joined
Jan 14, 2017
Messages
18,247
IMO There are three issues with control tip text.
1. There is a delay before it fires
2. It doesn't always 'fire' and I can never work out why
3. It's not that conspicuous to users

I prefer the mouse move event as suggested by the OP.

Add a hidden label on your form.
Suggest you use a large font size and a bright colour such as magenta as you want it to be noticed when visible.

Use the mouse move event to set the label caption and make it visible.
Add another mouse move event in the form detail if that's where the label is located.
This should set the caption to an empty string and hide it again

HTH
 
Last edited:

Sweetu

Registered User.
Local time
Today, 19:01
Joined
Sep 13, 2016
Messages
21
Hi Guys

I don't want to display a proper message box but just on the mouse hover event I want to display a text and it will hide automatically when no mouse hover on that label.

Any help will be much appreciated.

Thanks

you can use this also

Code:
    Dim SetTime As Integer, InfoBox As Object
    Set InfoBox = CreateObject("WScript.Shell")
    'Set the message box to close after your desired seconds
    SetTime = 2
    Select Case InfoBox.PopUp("Click OK (this window closes automatically after 2 seconds).", _
    SetTime, "This is your Message Box", 0)
        Case 1, -1
            Exit Sub
    End Select
 

NauticalGent

Ignore List Poster Boy
Local time
Today, 12:01
Joined
Apr 27, 2015
Messages
6,367
DoCmd.Execute Thirsty, dbPourAnotherOnError

I am ashamed to admit that I was actually thinking this was a real option for about 5 seconds.

Jeez, maybe I’ll go get a beer myself...
 

Beetle

Duly Registered Boozer
Local time
Today, 10:01
Joined
Apr 30, 2011
Messages
1,808
I am ashamed to admit that I was actually thinking this was a real option for about 5 seconds.

Jeez, maybe I’ll go get a beer myself...

Wait......what? You mean to tell me that won't automatically trap for my beverage handling errors?

All these years, operating under false pretenses. Now what? Back to square one I guess. Maybe Allen Browne has a solution on his site ;)
 

missinglinq

AWF VIP
Local time
Today, 12:01
Joined
Jun 20, 2003
Messages
6,423
I agree with ridders, vis-à-vis ControlTips being problematic, sometimes working, sometimes not...here's some boilerplate code fort the approach he outlined, with Textboxes named ControlA and ControlB and their corresponding Labels, ControlA_Label and ControlB_Label:
Code:
Private Sub Form_Load()
 ControlA_Label.Visible = False
 ControlB_Label.Visible = False
End Sub

Private Sub ControlA_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 ControlA_Label.Visible = True
End Sub

Private Sub ControlB_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 ControlB_Label.Visible = True
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
 ControlA_Label.Visible = False
 ControlB_Label.Visible = False
End Sub
Linq ;0)>
 

Wayne

Crazy Canuck
Local time
Today, 12:01
Joined
Nov 4, 2012
Messages
176
With respect to Control Tip Text, I found that sometimes it wouldn't work, but I discovered a fix. In the form design view, select the field you want the Tip Text to show for, if you right click on that field, select "Position", and then select "Bring to Front", and then save the form. The Control Tip Text will always display when you hover over that field.

I don't know the cause, but this works to fix it.

Wayne
 

isladogs

MVP / VIP
Local time
Today, 17:01
Joined
Jan 14, 2017
Messages
18,247
Thanks for the tip Wayne
I've just tested it on controls which weren't showing control tip text & can confirm your solution works.
However the long pause before it appears means I still favour using the mouse move event instead of control tips

Attached are two short video clips showing how I use the mouse move event to provide additional info as I move over buttons on a form.
In the second example, I also use it to show thumbnail images of various reports related to the buttons being moved over

The code used is similar to that outlined in post 3

HTH
 

Attachments

  • MouseMove.zip
    211.5 KB · Views: 314
  • MouseMove2.zip
    500.2 KB · Views: 275

Wayne

Crazy Canuck
Local time
Today, 12:01
Joined
Nov 4, 2012
Messages
176
Hi Colin,

I just checked out your videos. I really like where it shows a preview of the reports when you hover over the report buttons. I think I am going to try that on my db. Thanks for the inspiration.

Wayne
 

isladogs

MVP / VIP
Local time
Today, 17:01
Joined
Jan 14, 2017
Messages
18,247
That's proved a very popular feature where you have a long list of possible option - especially with users who only occasionally print the reports

Here's an example of the code used:

Code:
'In declarations section
Dim strFilename as String, strSelection As String

'Example MouseMove event code
Private Sub tglOption1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
      strFilename = "IncidentAnalysis1Month.gif" 'image file to display
      strSelection = "Pastoral Incident Analysis Chart" 'label to display
      ShowExampleReport
End Sub

Code to show/hide the report thumbnail
Code:
Private Function ShowExampleReport()

On Error GoTo Err_Handler

    Me.lblImgReport.visible = True
    Me.imgReport.PictureType = 1
    Me.imgReport.visible = True
    'gets full path name using folder path stored in a table - adapt as appropriate
    Me.imgReport.Picture = GetSchConstantsValue("strImagesPath") & strFilename 
    Me.cmdHide.visible = True
    Me.cmdZoom.visible = True

Exit_Handler:
    Exit Function

Err_Handler:
    If Err.Number = 2220 Then
        HideExampleReport
    Else
       MsgBox "Error " & err.Number & " in ShowExampleReport procedure", vbExclamation, "Application error"
    End If
    Resume Exit_Handler
    
End Function

Private Function HideExampleReport() 

On Error GoTo Err_Handler

    Me.lblImgReport.visible = False
    Me.imgReport.visible = False
    Me.imgReport.Picture = ""
    Me.btnClose.SetFocus
    Me.cmdHide.visible = False
    Me.cmdZoom.visible = False

Exit_Handler:
    Exit Function
    
Err_Handler:
    MsgBox "Error " & err.Number & " in HideExampleReport procedure", vbExclamation, "Application error"
    Resume Exit_Handler
    
End Function

HTH
Good luck.
 
Last edited:

missinglinq

AWF VIP
Local time
Today, 12:01
Joined
Jun 20, 2003
Messages
6,423
Another big advantage of using MouseMove and Labels, over ControlTips, is, as ridders touched on, that you can can position the text where you want it, and you can Format it in a way that makes it obvious to the user and easy to read.

Linq ;0)>
 

Users who are viewing this thread

Top Bottom