mousemove

Jake2

New member
Local time
Yesterday, 22:10
Joined
Jul 22, 2023
Messages
10
I am trying to change the color of text for a command button, then return to the original color after it is passed. I can get the text to change, but the funny thing is that it does not change until the mouse leaves the button, which defeats the purpose of "Mouseover". And I still need to change it back to the original. Solutions?

Cheers,
 
With the text change, you have to make use of the MouseMove event for the button (to change the text), then the MouseMove event for the Detail section of the form (to change it back).
Be careful to leave room around your button. If it is too close to another control or border, the MouseMove event may not fire.

Code:
Option Compare Database
Option Explicit

Dim strCaption As String

Private Sub Command0_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Change
Me.Command0.Caption = "changed"
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
'Change Back
Me.Command0.Caption = strCaption
End Sub

Private Sub Form_Open(Cancel As Integer)
'What to change back to?
    strCaption = Me.Command0.Caption
End Sub

With the colour change, as noted above, use the Hover Color and Hover Fore Color properties of the button.

Jack
 
Me.Command0.Caption = "changed"
To stop flicker use
Code:
If Me.Command0.Caption <> "changed" and then Me.Command0.Caption = "changed"

However agree with pat since this is about colour not caption - use the hover fore color property
 

Users who are viewing this thread

Back
Top Bottom