Solved Make a label on form Toggle BOLD & NORMAL when mouse pointer hover/move off (1 Viewer)

Jason Lee Hayes

Active member
Local time
Today, 06:25
Joined
Jul 25, 2020
Messages
175
Hi,

I wish to make the label BOLD when hovering above it with the mouse then when the mouse is moved away from the label the bold is reduced back to its default NORMAL size..

Its a nicety not a necessity for my project...

Been searching and came across this code:-

Make label bold when cursor hovers - Microsoft: Access Forms - Tek-Tips

Unfortunately when a create a module it fails to compile and i get an INVALID USE OF ME KEYWORD ERROR

Code:
Option Compare Database
Dim strCtl As String
Dim blnSet As Boolean

Function fSetBold(sI As String)
    ' this sets Bold on for the control name passed
    ' it also turns Bold off of the last control
    ' that was set using this function if it wasn't
    ' already reset using function fResetBold()
    If blnSet = False Then 'prevents flickering
        If strCtl <> "" And strCtl <> Null Then
            Me(strCtl).FontBold = False
        End If
        Me(sI).FontBold = True
        strCtl = sI ' store the name of this control to a variable
        blnSet = True ' store a value to the variable
    End If
End Function

Function fResetBold()
' This turns off Bold when the cursor
' leaves the control and does not need a
' value for the control's name passed because
' it uses the value in the variable strCtl
If blnSet = True Then
 If strCtl <> "" Then
  Me(strCtl).FontBold = False
 End If
 blnSet = False
End If
End Function

Any help would be appreciated; maybe something to do with not dimensioning ME..

Thanks in advance
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 00:25
Joined
Feb 28, 2001
Messages
27,186
To do this, you would need to track mouse movements and have some events set up and know the coordinates that contain your label or control.


Here is a way someone did some things not too different from what you ask.
 

Gasman

Enthusiastic Amateur
Local time
Today, 06:25
Joined
Sep 21, 2011
Messages
14,299
You cannot use Me in a module.
Me refers to the parent object like form or report.

Likely need to pass the frm as an object and use the name assigned to that in place of Me.

Test it out in a form first, and when that works, move it to a module and adjust the naming to suit.
 

Jason Lee Hayes

Active member
Local time
Today, 06:25
Joined
Jul 25, 2020
Messages
175
To do this, you would need to track mouse movements and have some events set up and know the coordinates that contain your label or control.


Here is a way someone did some things not too different from what you ask.
Hi,

Thanks for the link... This has worked; i find it a little strange that you have to put a label Infront of another label to toggle BOLD. It does have its drawbacks in that if you move out of the front facing label too quick sometimes its not recognized therefore not toggling but its better than nothing... Thankyou
 

Jason Lee Hayes

Active member
Local time
Today, 06:25
Joined
Jul 25, 2020
Messages
175
You cannot use Me in a module.
Me refers to the parent object like form or report.

Likely need to pass the frm as an object and use the name assigned to that in place of Me.

Test it out in a form first, and when that works, move it to a module and adjust the naming to suit.
Thanks,

Will do just that - The_Doc_Man solution worked but not without its drawbacks...
 

Jason Lee Hayes

Active member
Local time
Today, 06:25
Joined
Jul 25, 2020
Messages
175
You cannot use Me in a module.
Me refers to the parent object like form or report.

Likely need to pass the frm as an object and use the name assigned to that in place of Me.

Test it out in a form first, and when that works, move it to a module and adjust the naming to suit.
Hi, you were correct - did as you suggest and it works. I went with The_Doc_Man suggestion in the end as it was far less coding and only needed it for a single label. Thankyou..
 

Users who are viewing this thread

Top Bottom