473,382 Members | 1,717 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

MS Access Mouse Over Event

Can anyone assist me with creating a mouse over event for objects on an Access form? I am trying to create customized tooltips for users of a database application I created. I am using MSAccess 2000.
Nov 7 '06 #1
6 11806
missinglinq
3,532 Expert 2GB
Using the MouseMove event (which is commonly referred to as Mouse Over) basically consists of two parts, setting up the action to be taken if the cursor travels across an object, such as a label or text box, and re-setting that action to the neutral state, if you will.

The following example changes the text color to red on a label (MyLabel) when the cursor passes over it, then changes the text color back to black when the cursor leaves the label.

Private Sub MyLabel_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MyLabel.ForeColor = vbRed
'Sets the text color to Red on MouseMove over label
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
MyLabel.ForeColor = vbBlack
'Sets the text color back to Black on MouseMove over Detail Section of Form
End Sub

The action would be repeated for each individual object's MouseMove event, with the re-setting statement added to the shared Detail_MouseMove sub.

This is basically how it is done. You can substitute whatever events you want to occur in place of the above text color changing. One idea would be to have a label (ToolTipLabel) on your form and to change the caption depending on which object the cursor was on. Set the alignment property for the label to "Centered" so that the text will always look balanced.
Assuming the object we're dealing with is a label named MyLabel:

Private Sub MyLabel_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
ToolTipLabel.Caption = "This is a tool Tip"
'Place your tool tip here
End Sub

Private Sub Detail_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
ToolTipLabel.Caption = ""
'Replace the tool tip with a blank string here
End Sub

As I said, these are just two examples of what you can do with MouseMove. Have at it!
Nov 7 '06 #2
MMcCarthy
14,534 Expert Mod 8TB
Can anyone assist me with creating a mouse over event for objects on an Access form? I am trying to create customized tooltips for users of a database application I created. I am using MSAccess 2000.
What help exactly do you need?

1. Do you know where to put a mouse over event?
2. Do you know how you want to display the tooltips?
3. Do you want to know what code to use to do it?
Nov 7 '06 #3
NeoPa
32,556 Expert Mod 16PB
Excellent answer (Not your's THIS time Mary).
Nov 8 '06 #4
MMcCarthy
14,534 Expert Mod 8TB
Excellent answer (Not your's THIS time Mary).
Yes I've been noticing Missinglinq

Not that many posts so far but what there is, is good and to the point.

Keep it up Missinglinq and welcome to the forum.

Mary
Nov 8 '06 #5
I have been using a Public function for a while that covers mouse over effects for just about everything you can put on a form.

I am attaching the code here, you can also find my article on how to do this on EE. Here:
** Edit ** <Snip>

Here is my new code for MOE in Access:

Put this at the very top of your VB editor for your form.

Expand|Select|Wrap|Line Numbers
  1. Private Function Hover(Optional pstrName As String)
  2.  
  3.     Static sstrHover As String
  4.  
  5.     If sstrHover = pstrName Then Exit Function
  6.     If Len(sstrHover) Then
  7.         ' remove hover effect
  8.         With Me(sstrHover)
  9.             Select Case .ControlType
  10.             Case acTextBox
  11.                 .ForeColor = vbBlack
  12.                 .FontSize = 11
  13.                 .FontBold = True
  14.                 If .Controls.Count Then .Controls(0).ForeColor = vbBlack
  15.             Case acRectangle
  16.                 .BorderColor = vbBlack
  17.             Case acLabel
  18.                 .ForeColor = vbBlack
  19.                 .FontSize = 11
  20.                 'If .Controls.Count Then .Controls(0).ForeColor = vbBlack
  21.             Case acCommandButton
  22.                 .ForeColor = vbBlack
  23.                 .FontSize = 11
  24.                 .FontBold = True
  25.             End Select
  26.         End With
  27.     End If
  28.     sstrHover = pstrName
  29.     If Len(sstrHover) Then
  30.         ' set hover effect, change font color
  31.         With Me(sstrHover)
  32.             Select Case .ControlType
  33.             Case acTextBox
  34.                 .ForeColor = vbRed
  35.                 .FontSize = 14
  36.                 If .Controls.Count Then .Controls(0).ForeColor = vbRed
  37.             Case acRectangle
  38.                 .BorderColor = vbRed
  39.             Case acLabel
  40.                 .FontSize = 14
  41.                 .ForeColor = vbRed
  42.                 'If .Controls.Count Then .Controls(0).ForeColor = vbRed
  43.             Case acCommandButton
  44.                 .ForeColor = vbRed
  45.                 .FontSize = 14
  46.             End Select
  47.         End With
  48.     End If
  49.  
  50. End Function
Then to get your control to show the effects use this code:

Expand|Select|Wrap|Line Numbers
  1. Private Sub myControl_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
  2. Hover myControl.Name
  3. End Sub
Works like a charm.

Have fun.

TLH
Aug 9 '10 #6
NeoPa
32,556 Expert Mod 16PB
Thanks for posting TLH. As a newbie to the forum you may not yet be aware of our rules so I've had to edit your post to comply.

Welcome to Bytes!
Aug 9 '10 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: John Champaign | last post by:
Hi all, I'm working on an educational applet for a child with special needs. He's got a bit of a trick to make my life more difficult... To interact with the applet he needs to click on...
9
by: punkin | last post by:
I am trying to catch mouse position on the entire screen by dynamically generating mouse click event at every 100 ms. My code only works for IEs but not any Netscape or Gecko-based browsers. The...
5
by: gsb | last post by:
I track the mouse location like this code: function mousePos(e) { var p = new Object(); if(e) { p.x = e.pageX; p.y = e.pageY; } else { p.x = event.x; p.y = event.y; } ... (show) }...
3
by: mitsura | last post by:
Hi, I have included a small listing. The test program opens a panel and show a bitmap. What I want is to when the mouse is over the bitmap panel, I want to trap the left mouse click. The...
6
by: AccessWhiz | last post by:
I have been trying desperately for the past few days to figure out why the MouseWheel solution that I retrieved from the Lebans website won't work. The access database included with the solution...
3
by: Logan Mckinley | last post by:
I need to be able to detect mouse movement even when it is not over my application. I can get the mouse cords using MousePosition but I am not sure if there is an event that hits my program when...
0
by: lechatthierry | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT...
1
by: Neko | last post by:
Is it possible to block a mouse event on an Hyperlink with a general script event? This is quite troublesome for me. I am trying to find a way to block the windows shortcut SHIFT + MOUSE LEFT...
3
by: wanwan | last post by:
I made a game with a window form that needs to record the mouse position to an array at 100 samples per second, so I use the mouse move event to do the job. The problem is the mouse move event...
2
by: Horst JENS | last post by:
Hi group, have problems with combobox-control in a form (access 2003). I added VBA-Code to on-Change event of the control. If the user choose an value from the control, the filter of the form...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.