Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Colorfull Command Buttons

Introduction.

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 maybe expecting about a 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 the 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, maybe 3 minutes when you create it for the first time. You can create the variants of the same button in less than one minute.

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 a few changes in the Property Sheet of the Button. Maybe one or two lines of Code for Button Animation and you are ready to roll.

Designing the Button.

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

     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 in the Toolbar above, you can click on it to bring it up too.

  2. Click on the AutoShapes - -> Basic Shapes - -> Rounded Rectangle Tool.

  3. Draw a Rounded Rectangle.

  4. Right-Click on the shape that you have just drawn and select Format AutoShape from the Shortcut Menu.

  5. Select the Colors and Lines Tab on the displayed control and Click on the Color drop-down list under the Fill values group.

  6. Click on the Yellow Color on the Color Palette and then Click on the Fill Effects. . . Control.

  7. 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 on the right.

  8. Click OK and OK again on the Format AutoShape control to paint the Rounded Rectangle with the selected gradient color.

  9. Right-Click on the shape and select Edit Text from the displayed Shortcut Menu.

  10. Type the Button Caption, say Data Files. Highlight the text and use normal Word Formatting tools viz. Align Center, Bold, and Font Color that has better visibility on the Gradient Background.

    Note: Once you copy and paste the Button on the 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 the 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 selecting the shape you like the most for a Button.

  11. Right-Click on the Button and select Copy from the Shortcut Menu.

  12. Minimize Word and open the Access Form that you have kept open in Design View.

  13. 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.

  14. Right-Click on the Button and select Properties from the Shortcut Menu.

  15. 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. In this background area, we can fill up with the color of the Form so that when the Form opens in Normal View this will not be visible.

  16. If the button is in the Footer Section of your Form then, click on the Footer Section of the Form to select it and display the Property Sheet.

  17. Copy the Back Color Property Value of the Form.

  18. Click on the button to display the Property Sheet of the Button.

  19. Paste the value in the Back Color property copied from the Form.

  20. Change the Special Effect Property to Raised.

  21. Change the Border Style Property to Transparent.

  22. 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.

  23. 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

  24. Copy the correct name of the Button, from its Name Property and paste it for replacing OLEUnbound257. See that you are not deleting the dot separator after the word Me. And at the beginning of  .SpecialEffect while pasting the Button Name.

  25. Select the Form's Section (Detail or Footer or Header) where you have placed the Command Button and display the Property Sheet.

  26. 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.

  27. Change the Value 2 to 1.

Animating the Button.

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 do you think about them?

 

  1. Command Button Animation
  2. Double Action Command Button
  3. Colorful Command Buttons
  4. Transparent Command Button
  5. Command Button Animation-2
  6. Creating Animated Command Button with VBA
  7. Command Button Color Change on Mouse Move

Share:

5 comments:

  1. it does work,

    however:

    - pls open windows task manager, then click performance tab.

    - then go back to the form containing those buttons

    - pls drag the mouse-pointer over the form again and again..

    - see on windows task manager, u will notice that the CPU usage is getting higher...

    because ms access always proceed "on move event" everytime we drag the mouse over the form...

    regards
    a SAP Lover
    romy

    ReplyDelete
  2. Yes it does work,


    however, pls do the following steps:


    - pls open windows task manager, then click performance tab.

    - then go back to the form containing those buttons

    - then pls drag the mouse over the form again and again..

    - see on windows task manager, u will notice that the CPU usage is getting higher...
    because ms access always proceed "on move event" everytime we drag the mouse over the form...

    regards
    a SAP Lover

    ReplyDelete
  3. Yes, you have a point there. But the Mouse Movements are always monitored by the system and a certain level of increase in CPU usage also noticed when the Mouse is in motion elsewhere.

    The statement in question (
    Me.OLEUnbound257.SpecialEffect = 2) can be put in test and prevent it from setting the value repeatedly when the value is already set, which will reduce the activity to a certain degree, like:

    If
    Me.OLEUnbound257.SpecialEffect = 2 then

    Me.OLEUnbound257.SpecialEffect = 1

    End If

    ReplyDelete
  4. I like the ability to add buttons with color to my Access forms. I have noticed one drawback, however, possibly because I have done something wrong.

    When colored buttons are created using the Copy/Paste from Word, the buttons on the Access form do not appear in the Tab Sequence. When I run the form in form view, I cannot tab to the buttons, nor can I "click" them using the spacebar or enter key like I can for normal buttons. This is a drawback to my GUI, which is very keyboard intensive.

    Have I done something wrong, or is this the correct functionality?

    Thanks
    GRC

    ReplyDelete
  5. This is a known issue that it doesn't have the Tab Order Property. You have done nothing wrong. As an alternative measure you can create a Transparent Command Button (http://www.msaccesstips.com/2008/04/transparent-command-button/) with the same size and place it over the Colorful Comand Button and then you can set the tab order property value of the transparent command button. When you set the Transparent Property of a Normal Command Button to Yes; it becomes transparent or invisible.

    Regards,
    a.p.r. pillai

    ReplyDelete

Comments subject to moderation before publishing.

PRESENTATION: ACCESS USER GROUPS (EUROPE)

Translate

PageRank

Post Feed


Search

Popular Posts

Blog Archive

Powered by Blogger.

Labels

Forms Functions How Tos MS-Access Security Reports msaccess forms Animations msaccess animation Utilities msaccess controls Access and Internet MS-Access Scurity MS-Access and Internet Class Module External Links Queries Array msaccess reports Accesstips WithEvents msaccess tips Downloads Objects Menus and Toolbars Collection Object MsaccessLinks Process Controls Art Work Property msaccess How Tos Combo Boxes Dictionary Object ListView Control Query VBA msaccessQuery Calculation Event Graph Charts ImageList Control List Boxes TreeView Control Command Buttons Controls Data Emails and Alerts Form Custom Functions Custom Wizards DOS Commands Data Type Key Object Reference ms-access functions msaccess functions msaccess graphs msaccess reporttricks Command Button Report msaccess menus msaccessprocess security advanced Access Security Add Auto-Number Field Type Form Instances ImageList Item Macros Menus Nodes RaiseEvent Recordset Top Values Variables Wrapper Classes msaccess email progressmeter Access2007 Copy Excel Export Expression Fields Join Methods Microsoft Numbering System Records Security Split SubForm Table Tables Time Difference Utility WScript Workgroup database function msaccess wizards tutorial Access Emails and Alerts Access Fields Access How Tos Access Mail Merge Access2003 Accounting Year Action Animation Attachment Binary Numbers Bookmarks Budgeting ChDir Color Palette Common Controls Conditional Formatting Data Filtering Database Records Defining Pages Desktop Shortcuts Diagram Disk Dynamic Lookup Error Handler External Filter Formatting Groups Hexadecimal Numbers Import Labels List Logo Macro Mail Merge Main Form Memo Message Box Monitoring Octal Numbers Operating System Paste Primary-Key Product Rank Reading Remove Rich Text Sequence SetFocus Summary Tab-Page Union Query User Users Water-Mark Word automatically commands hyperlinks iSeries Date iif ms-access msaccess msaccess alerts pdf files reference restore switch text toolbar updating upload vba code