Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Equivalent/Workaround of MouseOut in VBA? 1

Status
Not open for further replies.

RP1America

Technical User
Aug 17, 2009
221
US
Word 2007

I have a checkbox on a userform where on hovering the mouse, I would like to show a label elsewhere on the form. Upon removing the mouse from hovering over the checkbox, I would like to remove visibility of the label.

I am aware of and have coded my MouseMove event of my checkbox. This takes care of hovering on the checkbox. Yet, I have found that there is no equivalent to an event of removing the mouse from hovering.

Anyone have a decent workaround?

Thanks!
Ryan
 


hi,

A button that toggles whether to or not?

Skip,

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 

What's the Container for your Checkbox? Is it a Form itself? A GroupBox, a Frame?

If, let's say, your checkbox is placed directly on a Form, you may just simply:
Code:
Option Explicit

Private Sub [blue]CheckBox1_MouseMove[/blue](ByVal Button As Integer, _
    ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
[green]Label1.Caption = "I am over CheckBox"[/green]
End Sub

Private Sub [blue]UserForm_MouseMove[/blue](ByVal Button As Integer, _
    ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
[green]Label1.Caption = ""[/green]
End Sub


Have fun.

---- Andy
 
Sorry, Skip, I don't think that's really what I'm looking for.

This label that is shown/hidden depending if you are hovering over the checkbox or not is very similar to the ControlTipText, yet I don't want to use the ControlTipText. I need that text to be in a specific "instructions" section of the form.
 
Haha! Thanks Andrzejek!

I tried exactly that, yet using my form name in place of "UserForm". Whoops!

That works perfectly! Thank you!
 
I need to add an IF statement to the UserForm_MouseMove procedure.

In addition to the checkbox, there are other controls (comboboxes and text boxes) that upon entry are displaying text in the label and upon exit are setting that text to blank.

The issue is that with the UserForm_MouseMove procedure as is, it is blanking out my label anytime the mouse is moved onto the userform. I only want it to blank out if upon UserForm_MouseMove the label previously contained the label text associated with the checkbox.

I attempted to set a boolean variable on the checkbox mousemove event and then check that variable upon the userform mousemove event. Then if it was set a certain way, to change the label back to "". If this is a way to do it, I am certainly missing something.

Thoughts?

Code:
Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

Dim bOff As Boolean

If bOff = 0 Then
    lblInfo.Caption = ""
End If

bOff = -1

End Sub

Code:
Private Sub chkCurrent_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)

Dim bOff As Boolean

lblInfo.Caption = "Uncheck if entering a task for a different day than current date" & Chr(13) & Chr(13) & "Check if entering a task for today"

bOff = 0

End Sub
 

Move [tt][blue]Dim bOff As Boolean[/blue][/tt] to General Declaration portion of your code (on the top, under Option Explicit, and before any events)

You also need to assign a value to it somewhere:

[tt]bOff = True[/tt]

and

[tt]bOff = False[/tt]

Have fun.

---- Andy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top