A Microsoft Access Database is a collection of information that has been organised so that the information are easy to access and display in different ways.
Building Access forms is a time consuming aspect to front-end database designs and in this Microsoft Access tutorial, I want to add some extra aesthetics and alternative control enhancements for you.
There are many Access form controls, formats and properties that can be applied to a form over and above the basics ranging from the more advanced conditional formatting options to the custom built controls including my recent post on coloured tab controls.
So hereâs some alternatives for your traditional command buttonâŚ
Using the standard command button, you can still apply different format effects using the correct event with some Access VBA code or adopt a different control altogether (i.e. a Label) and make this your button click action instead.
Hyperlinks are also another way to apply actions for opening another form or running a report and can exclude VBA code (for basic actions).
Microsoft Access Tutorial: How To Build Alternative Access Form Controls â The Command Button
Letâs work on and illustrate the alternative button option using a Label and some VBA code. Take a look at the following screenshot:
When you hover over an item in the dark blue banner, the item turns a subtle white from the resting light blue resetting all other menu items including the âCloseâ item.
Of course, you can set any format by adding a raise, sunken effect or enhancing with underline, bold, change the background or changing font sizes â itâs how creative do you want to be?
I used a Label control and set the default to a non-selected state. In this example, I used the following:
Set the Caption property as you may want to change the caption from say âOnâ to âOffâ.
Back Style property to âNormalâ
Back Color property to â#003366â which reflects the dark blue banner colour though could be set as transparent.
Border Style property set to âTransparentâ.
Border Width property set to âHairlineâ.
Border Color property set to âNo Colorâ.
Special Effect property set to âFlatâ.
Fore Color property set to â#7DBEDCâ (which is light blue colour).
You may want to look at my eBook on How to Build Access Database Forms for more detailed explanation on the above properties and general design techniques for your forms.
I would suggest you also apply some consistency to the names for your Labels that will be acting as a button as you could be clever to group and loop your Access VBA code more effectively. You could also adopt the Tag property to help separate this type of control use with others.
Well, you will probably want a public procedure to reset all controls and individually apply format changes to the selected item.
Therefore, using the main event called âOn Mouse Moveâ would be advisable. You will still need to add code the âOn Clickâ event so when users click the item it will execute the action of opening a form or report or whatever it is your want to action (which has been excluded in this article).
I created a public sub procedure called ResetMenuLabels that runs the following code:
(Please ignore the word âPrivateâ in the above code snippet. It should be âPublicâ as it should really be stored in a module (which this example doesnât use) making this available to any form).
The above Microsoft Access tutorial code will loop through all controls for your form but only check to first the active control is a Label type and that is had the Tag set as âlbâ (standing for Label Button). Providing you donât use this convention for any other control, you are pretty safe for this form to reset all label buttons back to the resting style.
Iâve only used a simple format here for illustrative purposes and of course would expect you take it to the next step and apply your chosen styles â simple fill in between the loop structure.
The added element now is to call this procedure for the individual controlâs âOn Mouse Moveâ event with the additions for highlighting this control standing out from all others.
Hereâs an example for the âCloseâ button label:
So now this Microsoft Access tutorial on how to use alternative buttons opens the mind a little further.
The downside unfortunately is this will add to the time consuming task for your Access form designs!
I would love to hear from you perfectionists out there on what alternative buttons you have adopted for you Access forms in the reply box below.