We have seen Double-Action Command Button in the earlier Post and Command Button Animation before and now it is time for adding some color to the Command Buttons. Take a look at some different Command Buttons in action on a Control Screen (Main Switchboard) of a sample Ms-Access Application.

Like to use them on your Application? You may be expecting some lengthy lectures from me about them. Or may be expecting about hundred or more lines of VBA Code to copy from the bottom of this Article to paste into your Project. Or you are getting prepared to download some MS-Access Add-Ons from Internet and install them into your machine. Probably one or two Library Files to link with your Project too, right?

No, you don't have to do any of those things to create and put these Command Buttons on your Project. You can create one Button in two minutes, well, may be 3 minutes when you create it for the first time. You can create the variants of the same button in less than one minute's time.

I know you waited for so long for me to come to the point. These Buttons are not created in MS-Access. We have to create them in MS-Word (if you prefer Excel, it's ok with me), copy and paste them into MS-Access Form, and make few changes in the Property Sheet of the Button. May be one or two lines of Code for Button Animation and you are ready to roll.

  1. Open your MS-Access Project and open a Form and keep it in Design View.
  2.  

  3. Open MS-Word and check whether the Drawing Toolbar is visible at the bottom above the Status Bar. If it is not there then select View – -> Toolbar – -> Drawing. If the Drawing Toolbar Button is visible on the Toolbar above, you can click on it to bring it up too.
  4. Click on the AutoShapes – -> Basic Shapes – -> Rounded Rectangle Tool.
  5. Draw a Rounded Rectangle.
  6.  

  7. Right-Click on the shape that you have just drawn and select Format AutoShape from the Shortcut Menu.
  8. Select Colors and Lines Tab on the displayed control and Click on the Color drop-down list under Fill values group.
  9. Click on the Yellow Color on the Color Pallette and then Click on the Fill Effects. . . Control.
  10. Select the Gradient Tab and select Vertical under Shading Styles and click on the right bottom corner shape under the Variants category. The selected shape appears under the Sample heading at the right.
  11. Click OK and OK again on the Format AutoShape control to paint the Rounded Rectangle with the selected gradient color.
  12. Right-Click on the shape and select Edit Text from the displayed Shortcut Menu.
  13. Type the Button Caption, say Data Files. Highlight the Text and use normal Word Formatting tools viz. Align Center, Bold and Font Color that have better visibility on the Gradient Backgroup.

    Note: Once you copy and paste the Button on MS-Access Form you cannot change the Caption or Formatting. You better save and keep the original Buttons in Word Document itself. If you need some changes on the Command Buttons later you can easily do that here, copy and paste it again with changes.

    You can make copies of this Button and follow Step 5 above onwards to change the Gradient Color and Caption, according to your needs.

    Tips:You can change the shape of the created Buttons by selecting Change AutoShape from the Draw Menu on the Drawing Toolbar and select the shape you like the most for a Button.

  14. Right-Click on the Button and select Copy from the Shortcut Menu.
  15. Minimize Word and open your Access Form that you have kept open in Design View.
  16. Right-Click on the Form Detail Section or Footer Section where you want to place the Command Button and select Paste. Drag and position the Button to the correct location.
  17. Right Click on the Button and select Properties from the Shortcut Menu.
  18. Keep the Property Sheet away from the Button (if it is overlapping the Button) and change the Size Mode property to different Modes from Clip to Zoom or Stretch and see how the Button behaves at different Modes.

    When the Zoom mode is selected the Button re-sizes itself maintaining the height and width proportions correctly based on the current frame size, but leaves some gap around the image. This background area we can fill up with the background color of the Form so that when the Form opens in Normal View this will not be visible.

  19. If the button is in the Footer Section of your Form then click at the Footer Section of the Form to select it and display the Property Sheet.
  20. Copy the Back Color Property Value of the Form.
  21. Click on the Button to display the Property Sheet of the Button.
  22. Paste the value in Back Color property copied from Form.
  23. Change the Special Effect Property to Raised.
  24. Change the Border Style Property to Transparent.
  25. Now you can program your Colorful Command Button like the normal MS-Access Command Button.

    If you look at the Property Sheet of this Command Button you can see that all the essential Properties and Events are available for Programming, using Event Procedures, Hyperlinks, Macros etc.

    I will give you one line of Code to put some life (Animation) into this Button so that it will respond when the mouse moves over it.

  26. Click on the Button's Mouse Move Property and select Event Procedure. Copy the following Code between the Empty Subroutine lines.

     

    
    Me.OLEUnbound257.SpecialEffect = 2
    
  27. Copy the correct name of the Button from its Name Property and paste it replacing OLEUnbound257. See that you are not deleting the dot separaters after the word Me. And at the beginning of .SpecialEffect while pasting the Button Name.
  28. Select the Form's Section (Detail or Footer or Header) where you have placed the Command Button and display the Property Sheet.
  29. Click on the Mouse Move Property and select Event Procedure, copy and paste the above line of Code with the Button Name change and paste between the empty Subroutine lines.
  30. Change the Value 2 to 1.

Initially the Button will be in a Raised Style. When the mouse is moved over the Button then it will be pushed in (Sunken). When the Mouse is moved out of the Button it will restore back to the Raised state. If you repeat this action in quick succession the Animation will be more evident.

We will learn some more tricks with Command Buttons.

 

What you think about them?