Mouse over effect and toggle theme button (1 Viewer)

normanred56

New member
Local time
Today, 08:46
Joined
Jan 5, 2021
Messages
1
Could someone link me a tutorial on how to create the mouse over effect in MS access? Preferably beginner friendly. My goal is for the button to switch from background black and white text to background white and black text when the cursor hovers above the button.
Is it possible to change the theme of the form with just a click of a button? I am making my forms in dark mode but i would like the ability to switch to light mode when requested.
Also, if it is possible, can anyone assist me in beautifying my MSAccess project?
 

Isaac

Lifelong Learner
Local time
Yesterday, 20:16
Joined
Mar 14, 2017
Messages
8,774
use MouseMove event for the hover.
use MouseMove event of the parent object that hosts the button to put it back to normal (this way when the cursor moves OFF the button--i.e., ON to the parent object, like the detail of a form probably), it goes back to normal.
 

isladogs

MVP / VIP
Local time
Today, 04:16
Joined
Jan 14, 2017
Messages
18,209
You don't need to use event code to change the button forecolor and backcolor. That is done from the button property sheet
1609864477103.png


Themes can only be changed in design view so any requested changes would require forms to be reopened in design view, make the change, save it and reopen the form. In my opinion probably not practical

The best way to improve the appearance of Access forms is to start by looking at examples of what you think are good practice then study what makes them work well. Don't just consider appearance. Usability is just as important if not more so.
 

Isaac

Lifelong Learner
Local time
Yesterday, 20:16
Joined
Mar 14, 2017
Messages
8,774
Thanks for this reminder, isladogs. So many things have changed (been added) in the modern versions, I forgot about that. I tend to use Mouse events fairly often, but it's usually because I like to provide longer and more detailed versions of control tip texts....I populate a label with detailed information on hover.
But here, definitely better to just use properties if possible.
 
Last edited:

isladogs

MVP / VIP
Local time
Today, 04:16
Joined
Jan 14, 2017
Messages
18,209
No problem.
I do use the mouse move event on command buttons (etc) when I want something else to change on the form e.g. to display help text in a textbox or label (I don't use control tips) or to make an image visible etc
 

CJ_London

Super Moderator
Staff member
Local time
Today, 04:16
Joined
Feb 19, 2013
Messages
16,607
it's a shame other controls (primarily labels and textboxes) don't have the same formatting effects available to buttons. Not just the mouse effects but the shape as well.

Is it possible to change the theme of the form with just a click of a button? I am making my forms in dark mode but i would like the ability to switch to light mode when requested.

Not using themes, but you can change things like backcolor/borders/fonts etc using vba code.

I have a table of user preferences which users can use to change the look of the app - something like

tblPreferences
PreferencePK
UserFK
ObjectType (form/control)
PropertyName
PropertyValue

A bit of vba code is run in the form open event to fetch the user preferences and apply them to the form/control properties. I actually fetch the data as part of the app login routine and store the values in a global recordset so I don't have to keep going back to the table in the form open event.

To manage the table you will need a 'theme' form the user can open to select colours etc. I have on this form a subform control so the user can choose a form to see the effect of the changes they make.

So you could just have a button that users can click to set a choice - then your table would have a choice field rather than a userFK and you would not need the theme form since you would populate the table yourself.
 

Users who are viewing this thread

Top Bottom