# mouseover effects in MS Access?



## wseehorn (Feb 22, 2003)

I'm prettying up an access database I've designed. One of the things I'd like to do is get a 'mouse over' effect.

What I'd like is to have the cmdButton change color when the cursor is over it, and change back when the cursor moves off of it.
(i.e. from blue to green then back to blue)

From the reading I've done I don't think I can do that, apparently the BackColor property can't be changed on a command button.

I'd settle for the ForeColor and FontSize changing that way.

I've figured out how to do it when the button gets/looses focus, but that's not what I want.

I have been able to get it to change font color and size when the cursor moves over the command button, but it is a one way change - it doesn't change back when the cursor moves off of it.

Am I asking for the impossible or for the merely difficult?

TIA 

Will


----------



## MustBNuts (Aug 21, 2003)

What does your code look like that changes font/size?


----------



## wseehorn (Feb 22, 2003)

This changes the font size and color when the cursor moves over it, but it is only a one way change, it doesn't change back when the cursor moves off of it.

Private Sub Command10_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command10.FontSize = 12
Command10.ForeColor = vbRed

End Sub


I did try using the same type of code in the "on enter" and "on exit" events, but that code doesn't respond to the cursor movement, it responds when the focus is gained/lost. I'm (incorrectly?) assuming that those two events are equivalent to the "on got focus" and "on lost focus" events, though I don't see why there'd be two identical events.


----------



## MustBNuts (Aug 21, 2003)

Okay, I think I found you a solution.

To fake out a "mouse out" event, choose the form on which you've created the command button. On this create a mousemove event to return the values to normal:

Private Sub frmApplication_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Command10.FontSize = 8
Command10.ForeColor = vbBlack
End Sub

(obviously, the frmApplication is a dummy name, but you get the idea)

This way, the moment the mouse moved off your command button, it changes back and gives the appearance of a mouseover event.

Hope this helps,

MBN


----------



## wseehorn (Feb 22, 2003)

Thanks very much for thinking of it. Making the form the "off" for the special effects did the job.

Now I just have to code each of the buttons (there are a bunch of them on that form)


----------



## MustBNuts (Aug 21, 2003)

Well, with any luck, you have them similarly named so cut and paste and a few keystrokes would do the trick... 

...or, better yet, create a function that is triggered by the mousemove, you send the name as a variable and kick it out that way....

MBN


----------



## wseehorn (Feb 22, 2003)

The more I learn the less I know. Could you suggest some web resources good for beginners at creating functions?


----------



## MustBNuts (Aug 21, 2003)

I usually just hack around and read the help files to accomplish what I need to do - and I have a lot of VB reference books.

For VB (which is great for Access) try http://www.codeguru.com/vb/index.shtml

MBN


----------



## downwitchyobadself (Oct 13, 2000)

You can also write a single public procedure in which you pass a given command button, and then just reference that procedure in each mouse move event, like so:

```
Public Sub Highlight_MyCmdButton(pcmd as Access.CommandButton)
pcmd.FontSize = 8
pcmd.ForeColor = vbBlack
End Sub
```
Then, a typical mouse move event looks like this:

```
Private Sub Command10_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Highlight_MyCmdButton Command10
End Sub
```


----------

