Retrieve the 'hovered control'

JEEDEE

New member
Local time
Today, 13:06
Joined
May 29, 2016
Messages
5
Hello,

A difficult one: we have the 'screen' object with which you can do a bunch of things based on the 'activecontrol', 'activeform', aso ...

If you hover over a field, button, any control, it doesn't become active.
How to retrieve the name or content of the hovered control, in order to make something happen when you hover over the control?

In my case, I wrote a small public function which fills in a label, with extra info needed when I hover the control (on mouse over event)

But a lot of other things can happen if I only could retrieve the control I hover.

Any one?

Access 2015 Win10 64
 
How to retrieve the name or content of the hovered control, in order to make something happen when you hover over the control?

In my case, I wrote a small public function which fills in a label, with extra info needed when I hover the control (on mouse over event)
not quite sure what your problem is - the code in your small public function is presumably called by the controls 'mouse move' event - so you know the name of your control and can pass it as a parameter to a sub or function

in a module...

Code:
public sub changebackcolor (ctrl as control)
    ctrl.backcolor=vbred
end sub

in a form module for a control called 'somecontrol'

Code:
 private sub somecontrol_mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
     changebackcolour(me("somecontrol"))
 end sub
 
Hi,

Let me clarify.
There are hundreds of fields, buttons, lists, aso.
They are all in subforms, sometimes in datasheet view, sometimes not.
The tooltip does not work in subforms.
When a user hovers over a control (The db is in 3 languages), I want to be able to show the tooltip in a field somewhere on the form, the tooltip is stored in a table, storing the form and the control.

I found a way, by doing the following in designview, but it is a workaround.
(cnnstr is a function which opens a recordset of the table)

Code:
Public Function mo()


    Dim ctl As Control
   cnnstr ("T_TIPS")
   With rst
On Error Resume Next:   .MoveFirst: On Error GoTo 0
   
    For Each ctl In Screen.ActiveForm.Controls
 
         ctl.OnMouseMove = "=flashtip(""" & ctl.Name & """)"
        Do Until .EOF
        If !Naam = ctl.Name And !formulier = Screen.ActiveForm.Name Then
        GoTo vlgde
        Else
       .MoveNext
        End If
        Loop
       .AddNew
        !Naam = ctl.Name
        !formulier = Screen.ActiveForm.Name
        !belangrijk = MsgBox(Screen.ActiveForm.Name & " : " & ctl.Name & "Belangrijk?", vbYesNo)
        .Update
        .MoveFirst
vlgde:
    Next
End With
End Function
 
Last edited:
not sure if you are asking a question or saying this is the solution. If the former, please indent your code so it is readable and use the code tags (the # key on the advanced editor) to preserve the formatting
 

Users who are viewing this thread

Back
Top Bottom