<body><script type="text/javascript"> function setAttributeOnload(object, attribute, val) { if(window.addEventListener) { window.addEventListener("load", function(){ object[attribute] = val; }, false); } else { window.attachEvent('onload', function(){ object[attribute] = val; }); } } </script> <iframe src="http://www.blogger.com/navbar.g?targetBlogID=34083602&amp;blogName=LEARN+MS-ACCESS+TIPS+AND+TRICKS&amp;publishMode=PUBLISH_MODE_FTP&amp;navbarType=BLUE&amp;layoutType=CLASSIC&amp;searchRoot=http%3A%2F%2Fblogsearch.google.com%2F&amp;blogLocale=en_US&amp;homepageUrl=http%3A%2F%2Fwww.msaccesstips.com%2F" marginwidth="0" marginheight="0" scrolling="no" frameborder="0" height="30px" width="100%" id="navbar-iframe" allowtransparency="true" title="Blogger Navigation and Search"></iframe> <div></div>
www.msaccesstips.com

LEARN MS-ACCESS TIPS AND TRICKS


International Response Fund

LEARN MS-ACCESS TIPS AND TRICKS

↑ Grab this Headline Animator

Your Ad Here
Saturday, January 10, 2009

Command Button Animation-2

A Screen with Animated Text or Controls gives the application a lively look and feel than a rigid screen to the user as well as to the onlooker. Command Button Animation was the first Blog-Post that I have published on this site.


Another Screen design improvement was creating 3D headings on Form and Report with different Fonts, Sizes and Styles. Initially, created them manually and this lead to the creation of a 3D-Text Wizard. You can download this Wizard by following the highlighted link or from Downloads Menu.


You can find the details of 3D Text Styles in the following Posts and download the Wizard from any one of the Posts:


  1. Create 3D Headings on Forms

  2. Border 2D Heading Text

  3. Border 3D Heading

  4. Shadow 3D Heading Style



IBM AS400 (iSeries) Screens influenced me to go along designing MS-Access Screens with dark background, data labels with light shades and information in Green text. Even though these are old text based screens better visibility of information is the main attraction of these screens.


But, when I started designing them I faced little problem with the Command Button Animation that was in use till that time because it was not designed for dark backgrounds. I had to invent a different animation method around the original command button. It is simple to design besides easy to implement without the use of too complex VBA code.


So, here it is for you and I hope you like it too. First, we will implement it with a simple and easy to understand method. After that we will write a common routine that can drive the animation on any form with one or two lines of Code.


  1. Open a new Form or an existing one.

  2. Select the Footer of the Form. If it is not visible select Form Header/Footer from View Menu.

  3. Display the Property Sheet (View - ->Properties).

  4. Change the Back Color Property Value to 0.

  5. Select the Command Button Tool from Toolbox and draw a Command Button in the Footer Section of the Form.

  6. Display the Property Sheet of the Command Button.

  7. Change the Name property Value to cmdExit and Caption property value to Exit.

  8. Select the Rectangle Tool from Toolbox and draw a rectangle around the Command Button as shown in the sample design below:

  9. Button Animation Style-2

  10. Give a little more gap, between the button and the rectangle at the bottom and the right side than above and left, giving it a feel that the Command Button is in a raised state.

  11. Click on the Rectangle and display its Property Sheet.

  12. Change the Name Property Value to ExitBox and the Visible Property Value to No.


  13. Now, it is time to implement the animation trick. This time, we will not animate the button like we did earlier on the Command Button Animation; instead the Box around it will be made visible or hidden based on the Mouse movement over the Command Button.


    We will track the mouse movement in Code. When the mouse is over the Command Button the rectangle is made visible and when the mouse moves out it is hidden. When this action is repeated it will look like the command button become raised and goes flat again. It has a better look and feel in dark background rather than remains flat all the time.


    We need to place Code at two places to trap the mouse movements, on the On Mouse Move Event of the Command Button and on the On Mouse Move Event in the Form Footer.


  14. Select the Command Button.

  15. Display the Property Sheet of the Command Button (View - ->Properties).

  16. Select [Event Procedure] in the On Mouse Move property and click on the build button ().

  17. Copy and paste the Code given below, between the sub-routine skeleton. You can ignore the first and last lines while copying as these will be present in the Module.


  18. Private Sub cmdExit_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Me.ExitBox.Visible = False Then
    Me.ExitBox.Visible = True
    End If
    End Sub


  19. Click anywhere within the Form Footer area and display the Property Sheet and repeat Step-14 above.

  20. Copy and paste the following Code into the empty skeleton of the sub-routine, as you did above:


  21. Private Sub FormFooter_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Me.ExitBox.Visible = True Then
    Me.ExitBox.Visible = False
    End If
    End Sub


    Actually, the IF…Then statement is not required in the routine. This is introduced to avoid changing the value repeatedly during mouse movements and to avoid flickering.


  22. Save the Form and open it in Normal view.

  23. Move the Mouse over and out of the Command Button repeatedly which will give the button a sense of going flat and raised state every time.


  24. When we implement this animation at several places duplicating the above code everywhere is not good programming. A common routine is given below that can be called with a one line code so that it is easy to implement anywhere and for any number of buttons.


  25. Copy and paste the Code given below into a Global Module of your database and save it.



Public Function AnimateFrame(ByVal OnOff As Boolean, ByVal x_Box As String)
Dim frm As Form, ctrl As Control
On Error GoTo AnimateFrame_Err

Set frm = Application.Screen.ActiveForm
Set ctrl = frm.Controls(x_Box)

Select Case OnOff
Case False
If ctrl.Visible = False Then Exit Function
frm.Controls(x_Box).Visible = False
Case True
If ctrl.Visible = True Then Exit Function
frm.Controls(x_Box).Visible = True
End Select

AnimateFrame_Exit:
Exit Function

AnimateFrame_Err:
Resume AnimateFrame_Exit
End Function


Now, we can replace the code we have written earlier with a single line Code each to display and hide the rectangle.



If Me.ExitBox.Visible = False Then
Me.ExitBox.Visible = True
End If


The above Code can be replaced with the statement


AnimateFrame True, "ExitBox"


in the On Mouse Move of Command Button and



If Me.ExitBox.Visible = True Then
Me.ExitBox.Visible = False
End If


can be replaced with the statement


AnimateFrame False, "ExitBox"


in the FormFooter_MouseMove event procedure.




StumbleUpon Toolbar



Form Menu Bars and Toolbars
Seriality Control - Missing Numbers
Wave Shaped Reminder Ticker
No Data and Report Error
Lost Links of External Tables

Labels:

0 Comments:

Post a Comment

Note:Comments subject to Review by Blog Author before displaying.

Links to this post:

Create a Link

<< Home


Creative Commons License
Learn MS-Access Tips and Tricks by msaccesstips.com is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 2.5 India License.



This Page is best viewed with 1280 x 1024 Resolution

   FEATURED LINKS
SITEMAP
Command Button Animation
3D Headings on Forms
MsgBox & Office Assistant
Reminder Ticker
MS-Access & E-Mails
Automated E-Mail Alerts
MsgBox with Options Menu
Colorful Command Buttons
Configure Lotus Notes
Alerts through Network
Running this site has become a costly affair as the revenue from Ads is not sufficient to support it. If you find these pages informative & useful and would like to extend a helping hand, then please do it here.





Link Back to us with this Button

Learn MS-Access

Copy and Paste this HTML Code in your Webpage


Add to Technorati Favorites

Programming Blogs - Blog Catalog Blog Directory
Powered by FeedBurner
Add to Google

Software
Computers blogs
TopOfBlogs




AddMe - Search Engine Optimization Submit Your Site Free!
Go BlogZ Ave Blogs
eBlogzilla Changing LINKS
LS Blogs Blogarama
blog search directory BlogUniverse
Find Blogs in Directory RSS Directory
blogskinny.com ShowcaseBlogs.com
Amfibi

Search Engine Optimization and SEO Tools
Dmegs Web Directory Takeaway for Sale Businesses For Sale
Free Submission Directory Free site submission

Free Listing
 





Free Page Rank Checker

AddThis Social Bookmark Button

Enter your email address:

Delivered by FeedBurner



Top Blogs


Microsoft Access is the Jewell among MS-Office suite of Applications. Its Security features are excellent and works fine in Network environment. MS-Access can link/upload data from any Data Source. Applications that you design should be user-friendly and visually pleasing too. Here I would like to share my experience in Microsoft Access Programming with you and I am sure that you will find them interesting too.

My Photo
Name: Ramachandran Pillai
Location: Cochin, India

I am not an Access Guru and not through MS-Access yet. More to learn and I don’t think that aspect has any end because others have their own style of using this tool. We can learn lot more tricks, other than what we already know, from others too. My programming skills in COBOL, BASIC, Turbo-C, dBase, FoxPro, Visual Basic & Basic HTML attained through self-learning. I wrote my first COBOL Program in 1975 for ICL1901, 3rd Generation Main Frame Computer. Worked as a Computer Operator (NCR VRX8555 Mainframe Machine upto 1990) with M/s. Y.B.A. Kanoo, Saudi Arabia. Started using MS-Access Ver.2 in 1996, when dBase III+ and Foxbase (later version Foxpro) were my favorite DBMS. During Last 13 Year period I have developed more than 45 In-House Applications (medium & small) under MS-Access for our Organization, a leading Automotive Company in Oman. All the Applications are fully Secured and runs under Windows Network. It is my pleasure to share my experience with others. Anything interesting that you would like to share with me, please do. My E-mail Address: aprpillai@msaccesstips.com


If you need a Demo of any of the Topic explained here, send me an E-mail to: aprpillai@msaccesstips.com
with the Topic Description, I shall try to send a sample database to you.


Access Tips | Email | Reports | Report Tricks | Graphs | Forms | Menus | Animation | Security | Internet | How TOs | Linking | Query | Progress Meter | Alerts | Process Tips | Access Functions |




Site Designed by:www.msaccesstips.com