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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Including comments on Forms 1

Status
Not open for further replies.

peterpcu

MIS
Sep 15, 2005
31
0
0
GB
Hi There,

Here's a challenging question - anyone know how to include a comments field or comments box on a user form, so that when the user moves the mouse over a label or any object for that matter, a comments message is displayed? [mouseover perhaps?]

Given the excellent responses I have received via this forum to date I am sure that someone will know the answer.

best Regards

Pete
 
Pete,

I'm assuming you're using an Excel, Word, etc. Userform.

Example:
On the Userform (named frmMain, let's say) you have an Image control containing a graphic image (icon of some sort perhaps), named imgIcon. There is also a label containing the comment message, named lblComment. The Userform code module would then contain these event handlers:
Code:
Private Sub imgIcon_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   lblComment.Visible = True
End Sub

Private Sub UserForm_MouseMove(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
   lblComment.Visible = False
End Sub

That's all there is to it! When the user moves the mouse over the graphic image, the message appears; then disappears when the mouse passes over the Userform.

Note: Set the Visible property of lblComment to false at design-time or in Userform_Initialize.


Regards,
Mike
 
Hi Mike,

Fantastic, this works a treat.

Many thanks,
Pete
 
Why go to all that trouble when you can just enter text into the ControlTipText property of the control?

Thanks and best regards,
-Lloyd
 
Lloyd,

One reason might be to control the positioning and formatting of the message. Particularly if the message is lengthy.


Regards,
Mike
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top