473,387 Members | 1,515 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,387 software developers and data experts.

How do i make a button highlight when you mouse or tab over it?

283 100+
Hello all,

What I have is a button that I want to make either hightlight or dissapear and then reapper when you mouse over or tab over the button. I had it working but then I kept getting a bunch of errors so I wanted to get some help on the matter.

What I did was is I took this code and put it in to a module;

Expand|Select|Wrap|Line Numbers
  1.  
  2. Function HighlightControl(ControlName As String)
  3.  
  4. With Me.Controls(ControlName)
  5. If .FontSize <> 13 Then
  6. .FontSize = 13
  7. .ForeColor = 49915
  8. End If
  9. End With
  10.  
  11. End Function
  12.  
  13. Function UnhighlightControls()
  14.  
  15. Dim ctl As Access.Control
  16.  
  17. For Each ctl In Me.Controls
  18. With ctl
  19. If .Tag = "Highlight" Then
  20. If .FontSize <> 12 Then
  21. .FontSize = 12
  22. .ForeColor = 16776960
  23. End If
  24. End If
  25. End With
  26. Next ctl
  27.  
  28. End Function
  29.  
Then I took another command
Expand|Select|Wrap|Line Numbers
  1. =UnhighlightControl(CommandButton)
  2.  
and put it in to the Expression Builder, OnMouseMove property of the button.
It started to work but then it just started to error out. Is there something Im missing or forgot to do?

Thanks in advance for the help
Mar 22 '10 #1
1 6069
ADezii
8,834 Expert 8TB
  1. Add both Functions to your Form's Code Module. I reformatted them and added Code Tags for clarity.
    Expand|Select|Wrap|Line Numbers
    1. Private Function UnhighlightControls()
    2. Dim ctl As Access.Control
    3.  
    4. For Each ctl In Me.Controls
    5.   With ctl
    6.     If .Tag = "Highlight" Then
    7.       If .FontSize <> 12 Then
    8.          .FontSize = 12
    9.          .ForeColor = 16776960
    10.       End If
    11.     End If
    12.   End With
    13. Next ctl
    14. End Function
    Expand|Select|Wrap|Line Numbers
    1. Private Function HighlightControl(ControlName As String)
    2. With Me.Controls(ControlName)
    3.   If .FontSize <> 13 Then
    4.     .FontSize = 13
    5.     .ForeColor = 49915
    6.   End If
    7. End With
    8. End Function
  2. For each Control that you wish to be involved in this Highlight/Unhighlight process:
    1. Set their Tag Property to Highlight
    2. In the Row next to the On Mouse Move Event Property, enter the following line where <Control Name> is the actual Name of the Control:
      Expand|Select|Wrap|Line Numbers
      1. =HighlightControl("<Control Name>")
  3. In the Row next to the On Mouse Move Event Property of the Form's Detail Section, enter the following line of Code:
    Expand|Select|Wrap|Line Numbers
    1. =UnhighlightControls()
  4. You should be good to go at this point.
Mar 23 '10 #2

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

Similar topics

6
by: Skip Hollowell | last post by:
I am working on a menu bar for a site, and am using buttons in the bar (because the customer wants to use accessKeys for each selection, apparently it is too much work to click on them with a...
11
by: VK | last post by:
Hi, I'm playing around with tables (TOM vs. DOM etc.) I cannot figure out an effective highlight mechanics for the cells: 1) No problems with: <td ...onMouseOver/Out background change> some...
0
by: jbbs | last post by:
I have a question regarding on the button and label. i don't know why when the mouse cursor points on the button, i see the button is flirking. is there anyway to make it not behave like that?...
18
by: jrhoads23 | last post by:
Hello, I am trying to find a way to tell if an .NET windows forms Button (System.Windows.Forms.Button) is "depressed" (pushed down). For my application, I can not use a check box control set to...
9
by: Devron Blatchford | last post by:
Hi there, Just wondering if I change the back and fore colour of a listview item when the mouse hovers over it? I want to overide the default windows colour. Can someone please tell me how to...
18
by: Colin McGuire | last post by:
Hi - this was posted last weekend and unfortunately not resolved. The solutions that were posted almost worked but after another 5 days of working on the code everynight, I am not further ahead....
5
by: marfi95 | last post by:
I'm very confused. I'm trying to automatically select the text when my textbox gets the focus. This is typically when the user has clicked the mouse in the field. This is the code I have in...
8
by: Jay | last post by:
I'm having a problem using lambda to use a command with an argument for a button in Tkinter. buttons = range(5) for x in xrange(5): buttons = Button(frame, text=str(x+1), command=lambda:...
4
by: Andrew Poulos | last post by:
As a user tabs about a web page I want to highlight with a, say, 2 pixel solid yellow border the anchor that currently has focus. When the anchor loses focus the border is removed. The anchors...
21
by: AdamOnAccess | last post by:
I am trying to set the focus on a button that sits on page 1 of my tab control. It looks like I'm successful at setting the focus because I see the highlight on the button, but when I push the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.