Learn Microsoft Access Advanced Programming Techniques, Tips and Tricks.

Colorfull Command Buttons

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?

 

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

Translate



PageRank
Your email address:

Delivered by FeedBurner

Search

Infolinks Text Ads

blog.feedspot.com Microsoft Access Blogs

Popular Posts

Search This Blog

Blog Archive

Powered by Blogger.

Labels

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

Featured Post

User-Defined Data Type-3

Last week we have learned how to define a User -Defined Data Type and it’s usage in programs.  If you have landed on this page, you may go t...

Labels

Blog Archive

Recent Posts