By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,495 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,495 IT Pros & Developers. It's quick & easy.

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

100+
P: 283
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
Share this Question
Share on Google+
1 Reply


ADezii
Expert 5K+
P: 8,597
  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

Post your reply

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